def iter_prepostorder(self, is_leaf_fn=None):
to_visit = [self]<EOL>if is_leaf_fn is not None:<EOL><INDENT>_leaf = is_leaf_fn<EOL><DEDENT>else:<EOL><INDENT>_leaf = self.__class__.is_leaf<EOL><DEDENT>while to_visit:<EOL><INDENT>node = to_visit.pop(-<NUM_LIT:1>)<EOL>try:<EOL><INDENT>node = node[<NUM_LIT:1>]<EOL><DEDENT>except TypeError:<EOL><INDENT>yield (False, node)<EOL>if not _leaf(node):<EOL><INDENT>to_visit.extend(reversed(node.children + [[<NUM_LIT:1>, node]]))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>yield (True, node)<EOL><DEDENT><DEDENT>
Iterate over all nodes in a tree yielding every node in both
pre and post order. Each iteration returns a postorder flag
(True if node is being visited in postorder) and a node
instance.