walkTree function
Visits all nodes in DFS pre-order, calling visitor on each.
If visitor returns false, stops the visit.
Implementation
bool walkTree(FNode root, bool Function(FNode node, FNode? parent) visitor,
{FNode? parent}) {
if (!visitor(root, parent)) return false;
for (final child in childrenOf(root)) {
if (!walkTree(child, visitor, parent: root)) return false;
}
return true;
}