code: def traversal(root):
      '''Tree traversal function that generates nodes. For each subtree, the 
      deepest node is evaluated first. Then, the next-deepest nodes are 
      evaluated until all the nodes in the subtree are generated.'''
      stack = [root]
      while len(stack) > 0:
          node = stack.pop()
          if hasattr(node,'children'):
              if node.children == set():
                  try:
                      stack[-1].children.remove(node)
                  except:
                      pass
                  yield (node,stack)
              else:
                  childnode = node.children.pop()
                  stack += [node,childnode]
          else: 
              children = [x for x in ast.iter_child_nodes(node)]
              node.children = set(children)
              stack.append(nodef traversal(root):
      '''Tree traversal function that generates nodes. For each subtree, the 
      deepest node is evaluated first. Then, the next-deepest nodes are 
      evaluated until all the nodes in the subtree are generated.'''
      stack = [root]
      while len(stack) > 0:
          node = stack.pop()
          if hasattr(node,'children'):
              if node.children == set():
                  try:
                      stack[-1].children.remove(node)
                  except:
                      pass
                  yield (node,stack)
              else:
                  childnode = node.children.pop()
                  stack += [node,childnode]
          else: 
              children = [x for x in ast.iter_child_nodes(node)]
              node.children = set(children)
              stack.append(node)
docs: Tree traversal function that generates nodes. For each subtree, the 
      deepest node is evaluated first. Then, the next-deepest nodes are 
      evaluated until all the nodes in the subtree are generated.