protected Result blendResults(Result result, Query q, int offset, int hits, Execution execution) {
        // Assert that there are more than one hitgroup and that there are only hitgroups on the highest level
        boolean foundNonGroup = false;
        Iterator<Hit> hitIterator = result.hits().iterator();
        List<HitGroup> groups = new ArrayList<>();
        while (hitIterator.hasNext()) {
            Hit hit = hitIterator.next();
            if (hit instanceof HitGroup) {
                groups.add((HitGroup)hit);
                hitIterator.remove();
            } else if ( ! hit.isMeta()) {
                foundNonGroup = true;
            }
        }

        if( foundNonGroup) {
            result.hits().addError(ErrorMessage.createUnspecifiedError("Blendingsearcher could not blend - there are toplevel hits" +
                                                                       " that are not hitgroups"));
            return result;
        }
        if (groups.isEmpty()) {
            return result;
        } else if (groups.size() == 1) {
            result.hits().addAll(groups.get(0).asUnorderedHits());
            result.hits().setOrderer(groups.get(0).getOrderer());
            return result;
        } else {
            if (blendingField != null) {
                return blendResultsUniquely(result, q, offset, hits, groups, execution);
            } else {
                return blendResultsDirectly(result, q, offset, hits, groups, execution);
            }
        }
    }
Produce a single blended hit list from a group of hitgroups.

This assumes that all hits are organized into hitgroups. If not, blending will not be performed.
container-search/src/main/java/com/yahoo/prelude/searcher/BlendingSearcher.java