private static void findAllTermNodes(final ExpressionItem node, final List<ExpressionTerm> termsFound) {
        // Don't go any further down this branch if this node is disabled.
        if (node.enabled()) {
            if (node instanceof final ExpressionTerm termNode) {
                termsFound.add(termNode);

            } else if (node instanceof final ExpressionOperator expressionOperator) {
                if (expressionOperator.getChildren() != null) {
                    for (final ExpressionItem childNode : expressionOperator.getChildren()) {
                        findAllTermNodes(childNode, termsFound);
                    }
                }
            }
        }
    }
Recursive method to populates the passed list with all enabled
{@link ExpressionTerm} nodes found in the tree.
stroom-statistics/stroom-statistics-impl-sql/src/main/java/stroom/statistics/impl/sql/search/StatStoreCriteriaBuilder.java