public boolean processSubTree(Predicate predicate) {
        if (predicate == null) {
            return false;
        }
        if (predicate instanceof Negation) {
            // All negations are for leaf-nodes after AndOrSimplifier has run.
            return true;
        } else if (predicate instanceof Conjunction) {
            List<Predicate> in = ((Conjunction)predicate).getOperands();
            List<Predicate> out = new ArrayList<>(in.size());
            List<Predicate> positiveChildren = new ArrayList<>(in.size());
            for (Predicate operand : in) {
                if (processSubTree(operand)) {
                    out.add(operand);
                } else {
                    positiveChildren.add(operand);
                }
            }
            out.addAll(positiveChildren);
            ((Conjunction)predicate).setOperands(out);
            return positiveChildren.isEmpty();
        } else if (predicate instanceof Disjunction) {
            List<Predicate> in = ((Disjunction)predicate).getOperands();
            List<Predicate> out = new ArrayList<>(in.size());
            List<Predicate> negativeChildren = new ArrayList<>(in.size());
            for (Predicate operand : in) {
                if (processSubTree(operand)) {
                    negativeChildren.add(operand);
                } else {
                    out.add(operand);
                }
            }
            out.addAll(negativeChildren);
            ((Disjunction)predicate).setOperands(out);
            return !negativeChildren.isEmpty();
        }
        return false;
    }
Returns true if the predicate ends in a negation.
predicate-search-core/src/main/java/com/yahoo/search/predicate/optimization/NotNodeReorderer.java