code: def generation(self):
          
          if not self.parent:
              return 0
          elif self.parent.is_dict:
              return 1 + self.parent.generation
          else:
              return self.parent.generation
docs: Returns the number of ancestors that are dictionaries