visit method
Applies the function f to all child nodes rooted from this node in
breadth first order.
Implementation
void visit(void Function(TreeNode<T> node) f) {
  final queue = Queue<TreeNode<T>>()..add(this);
  while (queue.isNotEmpty) {
    final node = queue.removeFirst();
    f(node);
    queue.addAll(node.children);
  }
}