protected function buildGroup(array $routes)
    {
        $groupCount = (int) $map = $regex = [];

        foreach ($routes as $route) {
            $params           = $route->getParams();
            $paramsCount      = count($params);
            $groupCount       = max($groupCount, $paramsCount) + 1;
            $regex[]          = $route->getPattern() . str_repeat("()", $groupCount - $paramsCount - 1);
            $map[$groupCount] = $route;
        }

        return ["~^(?|" . implode("|", $regex) . ")$~", $map];
    }