presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/AbstractResourceConfigurationManager.java/AbstractResourceConfigurationManager/getMatchingSpec
class AbstractResourceConfigurationManager:    protected ResourceGroupSpec getMatchingSpec(ResourceGroup group, SelectionContext<ResourceGroupIdTemplate> context)
    {
        List<ResourceGroupSpec> candidates = getRootGroups();
        ResourceGroupIdTemplate groupIdTemplate = context.getContext();
        ResourceGroupSpec match = null;

        for (ResourceGroupNameTemplate segment : groupIdTemplate.getSegments()) {
            match = null;
            for (ResourceGroupSpec candidate : candidates) {
                if (candidate.getName().equals(segment)) {
                    if (match != null) {
                        throw new PrestoException(INVALID_RESOURCE_GROUP, format(
                                "Ambiguous configuration for [%s] using [%s]. Matches [%s] and [%s]",
                                group.getId(),
                                groupIdTemplate,
                                match.getName(),
                                candidate.getName()));
                    }
                    match = candidate;
                }
            }

            checkState(match != null, "No matching configuration found for [%s] using [%s]", group.getId(), groupIdTemplate);
            candidates = match.getSubGroups();
        }

        verifyNotNull(match, "match is null");
        return match;
    }