public Predicate simplifyTree(Predicate predicate) {
        if (predicate instanceof Disjunction disjunction) {
            List<Predicate> newChildren =
                    disjunction.getOperands().stream().map(this::simplifyTree).toList();
            return compressFeatureSets(newChildren);
        } else if (predicate instanceof Negation negation) {
            negation.setOperand(simplifyTree(negation.getOperand()));
            return negation;
        } else if (predicate instanceof Conjunction conjunction) {
            List<Predicate> newChildren =
                    conjunction.getOperands().stream().map(this::simplifyTree).toList();
            conjunction.setOperands(newChildren);
            return conjunction;
        } else {
            return predicate;
        }
    }
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