nodes: 0, module; 1, function_definition; 2, function_name:ancestors_objects; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, expression_statement; 10, return_statement; 11, comment:"""Ancestors objects sorted by name."""; 12, assignment; 13, identifier:ancestor; 14, attribute; 15, block; 16, call; 17, identifier:ancestors_objects; 18, identifier:ancestors_objects; 19, list; 20, identifier:self; 21, identifier:ancestors; 22, try_statement; 23, expression_statement; 24, attribute; 25, argument_list; 26, block; 27, except_clause; 28, call; 29, identifier:ancestors_objects; 30, identifier:sort; 31, keyword_argument; 32, expression_statement; 33, attribute; 34, block; 35, attribute; 36, argument_list; 37, identifier:key; 38, lambda; 39, assignment; 40, identifier:GeoZone; 41, identifier:DoesNotExist; 42, continue_statement; 43, identifier:ancestors_objects; 44, identifier:append; 45, identifier:ancestor_object; 46, lambda_parameters; 47, attribute; 48, identifier:ancestor_object; 49, call; 50, identifier:a; 51, identifier:a; 52, identifier:name; 53, attribute; 54, argument_list; 55, attribute; 56, identifier:get; 57, keyword_argument; 58, identifier:GeoZone; 59, identifier:objects; 60, identifier:id; 61, identifier:ancestor
code: def ancestors_objects(self):
          """Ancestors objects sorted by name."""
          ancestors_objects = []
          for ancestor in self.ancestors:
              try:
                  ancestor_object = GeoZone.objects.get(id=ancestor)
              except GeoZone.DoesNotExist:
                  continue
              ancestors_objects.append(ancestor_object)
          ancestors_objects.sort(key=lambda a: a.name)
          return ancestors_objects