def postorder_traversal(node, keys=None):
 if isinstance(node, Basic):
  args = node.args
  if keys:
   if (keys != True):
    args = ordered(args, keys, default=False)
   else:
    args = ordered(args)
  for arg in args:
   for subtree in postorder_traversal(arg, keys):
    (yield subtree)
 elif iterable(node):
  for item in node:
   for subtree in postorder_traversal(item, keys):
    (yield subtree)
 (yield node)

def postorder_traversal ( node , keys = None ) : if isinstance ( node , Basic ) : args = node . args if keys : if ( keys != True ) : args = ordered ( args , keys , default = False ) else : args = ordered ( args ) for arg in args : for subtree in postorder_traversal ( arg , keys ) : ( yield subtree ) elif iterable ( node ) : for item in node : for subtree in postorder_traversal ( item , keys ) : ( yield subtree ) ( yield node )
do a postorder traversal of a tree .