public static function matchRouteCollection(
        RouteCollectionInterface $routeCollection,
        ServerRequestInterface $request,
        $pathOffset,
        array $parentParams
    ) {
        $methodFailureResult = null;
        $schemeFailureResult = null;

        foreach ($routeCollection as $name => $route) {
            if (null === ($matchResult = $route->match($request, $pathOffset))) {
                continue;
            }

            if ($matchResult->isSuccess()) {
                return MatchResult::fromChildMatch($matchResult, $parentParams, $name);
            }

            if ($matchResult->isMethodFailure()) {
                if (null === $methodFailureResult) {
                    $methodFailureResult = $matchResult;
                } else {
                    $methodFailureResult = MatchResult::mergeMethodFailures($methodFailureResult, $matchResult);
                }
                continue;
            }

            if ($matchResult->isSchemeFailure()) {
                $schemeFailureResult = $schemeFailureResult ?: $matchResult;
                continue;
            }

            return $matchResult;
        }

        if (null !== $schemeFailureResult) {
            return $schemeFailureResult;
        }

        if (null !== $methodFailureResult) {
            return $methodFailureResult;
        }

        return null;
    }