walk<T> static method
void
walk<T>()
Depth-first walk; visit receives each node and its ancestor path.
Implementation
static void walk<T>(List<TreeNode<T>> roots, void Function(TreeNode<T> node, List<TreeNode<T>> ancestors) visit) {
void rec(List<TreeNode<T>> nodes, List<TreeNode<T>> path) {
for (final n in nodes) {
visit(n, path);
if (n.children.isNotEmpty) rec(n.children, [...path, n]);
}
}
rec(roots, const []);
}