insertMatch method

void insertMatch(
  1. TargetTree tree,
  2. Match match,
  3. int index
)

Implementation

void insertMatch(TargetTree tree, Match match, int index) {
  TargetNode? root = findElement(children, (child) => child.accessor == match.paths[1][index]);

  if (root == null) {
    children.add(root = tree.makeNode(
        this,
        match.paths[1][index],  // step
        match.paths[1].length - 1 == index ? match : null
    ));
  }

  if (match.paths[1].length > index + 1) {
    root.insertMatch(tree, match, index + 1);
  }
}