private Set<Integer> identifyExtendedAttributesFields(final ExpressionOperator expr,
                                                          final Set<Integer> identified) {

        if (expr == null || expr.getChildren() == null) {
            return identified;
        }
        for (ExpressionItem child : expr.getChildren()) {
            if (child.enabled()) {
                if (child instanceof ExpressionTerm) {
                    ExpressionTerm term = (ExpressionTerm) child;

                    if (EXTENDED_FIELD_NAMES.contains(term.getField())) {
                        Optional<Integer> key = metaKeyDao.getIdForName(term.getField());
                        key.ifPresent(identified::add);
                    }
                } else if (child instanceof ExpressionOperator) {
                    identified.addAll(identifyExtendedAttributesFields((ExpressionOperator) child, identified));
                } else {
                    //Don't know what this is!
                    LOGGER.warn("Unknown ExpressionItem type " + child.getClass().getName() +
                                " unable to optimise meta query");
                    //Allow search to succeed without optimisation
                    return IntStream.range(metaKeyDao.getMinId(),
                            metaKeyDao.getMaxId()).boxed().collect(Collectors.toSet());
                }
            }
        }
        return identified;
    }
@return True if any term in any rule expression uses at least one of {@code fields}.
stroom-meta/stroom-meta-impl-db/src/main/java/stroom/meta/impl/db/MetaDaoImpl.java