private function addPathPartToTree(TreeNode $node, RoutePath $path, Route $route, int $index): TreeNode
    {
        $pathNode = $this->pathToNode($path, $route, $index);

        foreach ($node->getChildren() as $child) {
            if ($child->withoutChildren() == $pathNode->withoutChildren()) {
                return $child;
            }
        }

        $node->addChild($pathNode);

        return $pathNode;
    }