def METHOD_NAME(self, key, max):
    if key not in self.data:
        return
    n = len(self.data[key])
    if n <= max:
        return
    self.data[key] = self.data[key][:max]
    self.changed = True