walkTree<T, T1> function
Visit every node in a tree, call the fn
for each and collect the results
in an Iterable.
Implementation
Iterable<T1> walkTree<T, T1>(
TreeNode<T> root,
T1 Function(T node, Maybe<T> parent) fn, {
Maybe<T> parent = const None(),
}) sync* {
yield fn(root.value, parent);
for (final edge in root.edges) {
yield* walkTree<T, T1>(
edge,
fn,
parent: Just<T>(root.value),
);
}
}