private static Predicate compressFeatureSets(List<Predicate> children) {
        List<Predicate> newChildren = children.stream().filter(p -> !(p instanceof FeatureSet)).collect(Collectors.toCollection(ArrayList::new));
        children.stream()
                .filter(FeatureSet.class::isInstance)
                .map(FeatureSet.class::cast)
                .collect(groupingBy(FeatureSet::getKey,
                        reducing((f1, f2) -> {
                            f1.addValues(f2.getValues());
                            return f1;
                        })))
                .values()
                .stream()
                .map(Optional::get)
                .forEach(newChildren::add);
        if (newChildren.size() == 1) {
            return newChildren.get(0);
        } else {
            return new Disjunction(newChildren);
        }
    }
Simplifies Disjunction nodes where all children are of type FeatureSet. All FeatureSet that share the same key
are merged into a single FeatureSet. The Disjunction is removed if all children merges into a single feature set.

@author bjorncs
predicate-search-core/src/main/java/com/yahoo/search/predicate/optimization/OrSimplifier.java