protected function getRouteByUrl($url)
    {
        $url = str_replace($this->rootNode, '', $url);
        $nodes = explode(self::ROUTE_SEPARATOR, $url);
        $routeTree = $this->routeTree;
        $ids = [];
        $route = [];
        $countNodes = count($nodes);
        $uid = null;

        // Lookup route ...
        for ($i = 0; $i < $countNodes; ++$i) {

            // Is regular route way/node ?
            if (is_array($routeTree) && isset($routeTree[$nodes[$i]])) {
                $routeTree = $routeTree[$nodes[$i]];
            } elseif (preg_match('/{{(.*)}}/i', key($routeTree), $variable) > 0) {
                // maybe its a variable node value
                $nodes[$i] = '{{'.$variable[1].'}}';
                $id = $this->extractId($variable[1]);
                if ($id !== null) {
                    $uid = $id;
                }

                $ids[] = $nodes[$i];
                $routeTree = $routeTree[$nodes[$i]];
            } else {
                throw new Doozr_Base_Presenter_Rest_Exception(
                    'Route for URL "'.$url.'" seems wrong. It could not be resolved.',
                    400
                );
            }

            $route[] = $nodes[$i];

            if ($i === ($countNodes - 1)) {
                if (is_object($routeTree) === true) {
                    // Inject Ids for reverse lookup
                    /* @var $routeTree Doozr_Base_Presenter_Rest_Config */
                    $routeTree
                        ->id($uid)
                        ->ids($ids)
                        ->url($url)
                        ->realRoute($route)
                        ->rootNode($this->rootNode);
                } else {
                    // In this case we ended up before we got configuration!
                    throw new Doozr_Base_Presenter_Rest_Exception(
                        'Route for URL "'.$url.'" seems incomplete.',
                        406
                    );
                }
            }
        }

        return $routeTree;
    }