src/Matchers/Trees/TrieNode.php
public function addChild(TrieNode $childNode): self
    {
        if ($childNode instanceof LiteralTrieNode) {
            $this->addLiteralChildNode($childNode);
        } elseif ($childNode instanceof VariableTrieNode) {
            $this->addVariableChildNode($childNode);
        } else {
            throw new InvalidArgumentException('Unexpected trie node type ' . \get_class($childNode));
        }

        return $this;
    }
public function addChild(TrieNode $childNode): self
    {
        if ($childNode instanceof LiteralTrieNode) {
            $this->addLiteralChildNode($childNode);
        } elseif ($childNode instanceof VariableTrieNode) {
            $this->addVariableChildNode($childNode);
        } else {
            throw new InvalidArgumentException('Unexpected trie node type ' . \get_class($childNode));
        }

        return $this;
    }
Adds a child node and recursively merges all its children, too

@param $childNode $node The node to add
@return self For chaining
@throws InvalidArgumentException Thrown if the node was an invalid type