protected function createTree(&$keyParts, TreeNode $rootNode) : TreeNode
    {
        if (!count($keyParts)) {
            return $rootNode;
        }

        $newKey  = array_shift($keyParts);
        $newNode = new self($rootNode, $newKey, null, $rootNode->getKeyDelimiter());
        $rootNode->addChild($newNode);

        return $this->createTree($keyParts, $newNode);
    }