<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generation(self):
 """Returns the number of ancestors that are dictionaries"""

        if not self.parent:
            return 0
        elif self.parent.is_dict:
            return 1 + self.parent.generation
        else:
            return self.parent.generation