Visitor function type with state threading.
The type of state passed through the traversal
The element being visited
The depth level in the tree (0 = root)
Information about the edge leading to this element
Current state value
Tuple of [newState, stopDescent] where:
Visitor function type with state threading.