visit(self,
t,
pre_action=None,
post_action=None)
|
|
Visit every node in tree t and trigger an action for each node
before/after having visited all of its children. Bottom up walk. Execute
both actions even if t has no children. Ignore return results from
transforming children since they will have altered the child list of this
node (their parent). Return result of applying post action to this
node.
The Python version differs from the Java version by taking two
callables 'pre_action' and 'post_action' instead of a class instance that
wraps those methods. Those callables must accept a TreeNode as their
single argument and return the (potentially transformed or replaced)
TreeNode.
|