fun <Tree : TreeNode<Tree>, R> TreeNode<Tree>.fold(atom: Tree.() -> R, unary: Unary<*, Tree>.(R) -> R, binary: Binary<*, Tree>.(R, R) -> R): R
Standard tree fold. You can provide transformation operations for atoms, unary and binary nodes.
Useful for computing some aggregated function based on the tree structure or when transforming this tree to a completely different tree.
Compared to standard fold, we provide the current element as a target of an extension function, not as additional function argument.