void acceptSingleValue(String name,
                           boolean allowContent,
                           QueryProfileVisitor visitor,
                           DimensionBinding dimensionBinding) {
        FieldValues fieldValues = fieldValuesByName.get(name);
        if (fieldValues == null || ! allowContent)
            fieldValues = new FieldValues();

        fieldValues.sort();
        inheritedProfiles.sort();

        int inheritedIndex = 0;
        int fieldIndex = 0;
        // Go through both the fields and the inherited profiles at the same time and try the single must specific pick
        // from either of the lists at each step
        while(fieldIndex < fieldValues.size() || inheritedIndex < inheritedProfiles.size()) {
            // Get the next most specific from field and inherited
            FieldValue fieldValue = fieldValues.getIfExists(fieldIndex);
            FieldValue inheritedProfileValue = inheritedProfiles.getIfExists(inheritedIndex);

            // Try the most specific first, then the other
            if (inheritedProfileValue == null || (fieldValue != null && fieldValue.compareTo(inheritedProfileValue) <= 0)) { // Field is most specific, or both are equally specific
                if (fieldValue.matches(dimensionBinding.getValues())) {
                    visitor.acceptValue(name,
                                        fieldValue.getValue(),
                                        dimensionBinding,
                                        owner,
                                        fieldValue.getDimensionValues());
                }
                if (visitor.isDone()) return;
                fieldIndex++;
            }
            else { // Inherited is most specific at this point
                if (inheritedProfileValue.matches(dimensionBinding.getValues())) {
                    @SuppressWarnings("unchecked")
                    List<QueryProfile> inheritedProfileList = (List<QueryProfile>)inheritedProfileValue.getValue();
                    for (QueryProfile inheritedProfile : inheritedProfileList) {
                        if (visitor.visitInherited()) {
                            inheritedProfile.accept(allowContent,
                                                    visitor,
                                                    dimensionBinding.createFor(inheritedProfile.getDimensions()),
                                                    owner);
                        }
                        if (visitor.isDone()) return;
                    }
                }
                inheritedIndex++;
            }
            if (visitor.isDone()) return;
        }
    }
Visits the most specific match to the dimension binding of each variable (or the one named by the visitor)
container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java