addChild method

void addChild(
  1. TreeNode<T> child
)

Adds a single child to this node.

Implementation

void addChild(TreeNode<T> child) {
  child.parent = this;
  final delta = depth - child.depth + 1;
  if (delta != 0) child.visit((node) => node.depth += delta);
  _children.add(child);
}