public function optimize(RouteTree $routeTree)
    {
        $segmentDepthNodeMap = $routeTree->getSegmentDepthNodesMap();

        foreach ($segmentDepthNodeMap as $segmentDepth => $nodes) {
            $segmentDepthNodeMap[$segmentDepth] = $this->optimizeNodes($nodes);
        }

        return new RouteTree($routeTree->getRootRouteData(), $segmentDepthNodeMap);
    }