src/Graph/TreeNode.php
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);
    }
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);
    }
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 ) ; }
recursive way to build tree structure

@param array $keyParts
@param TreeNode $rootNode

@return TreeNode
recursive way to build tree structure