private static void addTerms(final ExpressionOperator expressionOperator,
                                 final Collection<String> fieldNames,
                                 final List<ExpressionTerm> terms) {
        // This if condition used to include
        // !Op.NOT.equals(expressionOperator.op()
        // but we have no idea why. If you remember why, then add it back in with a comment
        // explaining why
        if (ExpressionItem.isEnabled(expressionOperator) && expressionOperator.hasChildren()) {
            for (final ExpressionItem item : expressionOperator.getChildren()) {
                if (item.enabled()) {
                    if (item instanceof ExpressionTerm) {
                        final ExpressionTerm expressionTerm = (ExpressionTerm) item;
                        if (fieldNames == null || fieldNames.stream()
                                .anyMatch(fieldName ->
                                        fieldName.equals(expressionTerm.getField()) &&
                                        (Condition.IS_DOC_REF.equals(expressionTerm.getCondition()) &&
                                         expressionTerm.getDocRef() != null &&
                                         expressionTerm.getDocRef().getUuid() != null) ||
                                        (expressionTerm.getValue() != null &&
                                         !expressionTerm.getValue().isEmpty()))) {
                            terms.add(expressionTerm);
                        }
                    } else if (item instanceof ExpressionOperator) {
                        addTerms((ExpressionOperator) item, fieldNames, terms);
                    }
                }
            }
        }
    }
@return True if there are at least one enabled term under the expressionOperator
stroom-query/stroom-query-api/src/main/java/stroom/query/api/ExpressionUtil.java