private function traverseRouteListAndBuildMap($currentNode = null)
    {
        if (empty($currentNode)) {
            $this->traverseRouteListAndBuildMap($this->routes);
            return;
        }

        if (is_array($currentNode)) {
            foreach ($currentNode as $node) {
                $this->traverseRouteListAndBuildMap($node);
            }

            return;
        }

        if (!($currentNode instanceof Route)) {
            return;
        }

        $currentNodeName = $currentNode->getName();

        if (!empty($this->routeNameMap[$currentNodeName])) {
            $this->addDebugMessage("Duplicate route name " . $currentNodeName . " detected.");
        }

        $this->routeNameMap[$currentNodeName] =& $currentNode;

        if ($currentNode->getChildren()) {
            foreach ($currentNode->getChildren() as $child) {
                $this->traverseRouteListAndBuildMap($child);
            }
        }
    }