nodes: 0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, while_statement; 8, comment:"""
          Return an iterable of nodes, toplogically sorted to correctly import
          dependencies before leaf nodes.
          """; 9, attribute; 10, block; 11, identifier:self; 12, identifier:nodes; 13, expression_statement; 14, for_statement; 15, if_statement; 16, assignment; 17, identifier:node; 18, call; 19, block; 20, not_operator; 21, block; 22, identifier:iterated; 23, False; 24, attribute; 25, argument_list; 26, expression_statement; 27, expression_statement; 28, expression_statement; 29, identifier:iterated; 30, raise_statement; 31, identifier:self; 32, identifier:leaf_nodes; 33, assignment; 34, call; 35, yield; 36, call; 37, identifier:iterated; 38, True; 39, attribute; 40, argument_list; 41, identifier:node; 42, identifier:CyclicGraphError; 43, argument_list; 44, identifier:self; 45, identifier:prune_node; 46, identifier:node; 47, string:"Sorting has found a cyclic graph."
code: def sort(self):
          """
          Return an iterable of nodes, toplogically sorted to correctly import
          dependencies before leaf nodes.
          """
          while self.nodes:
              iterated = False
              for node in self.leaf_nodes():
                  iterated = True
                  self.prune_node(node)
                  yield node
              if not iterated:
                  raise CyclicGraphError("Sorting has found a cyclic graph.")