Well, basically you copied https://github.com/zendframework/zf2/blob/master/library/Zend/Mvc/Router/Http/TreeRouteStack.php#L309 ;)