private List<Object> applyAndOrOperators(final List<Object> in, final TokenType tokenType, final Op op) {
            final List<Object> out = new ArrayList<>(in.size());
            Object previous = null;
            for (int i = 0; i < in.size(); i++) {
                final Object object = in.get(i);
                if (object instanceof final AbstractToken token && tokenType.equals(token.getTokenType())) {
                    if (previous instanceof final ExpressionItem previousExpressionItem) {
                        // Get next token.
                        i++;
                        if (i < in.size()) {
                            final Object next = in.get(i);
                            if (next instanceof final ExpressionItem expressionItem) {
                                previous = ExpressionOperator
                                        .builder()
                                        .op(op)
                                        .children(List.of(previousExpressionItem, expressionItem))
                                        .build();
                            } else {
                                throw new TokenException(token, "Expected term after " + tokenType.name());
                            }
                        } else {
                            throw new TokenException(token, "Trailing " + tokenType.name());
                        }

                    } else {
                        throw new TokenException(token, "Expected term before " + tokenType.name());
                    }
                } else {
                    if (previous != null) {
                        out.add(previous);
                    }
                    previous = object;
                }
            }
            if (previous != null) {
                out.add(previous);
            }
            return out;
        }
@param isLenient Ignores any additional child tokens found. This is to support getting just
                 the data source from a partially written query, which is likely to not be
                 a valid query. For example, you may type
                 <pre>{@code from View sel}</pre> and at this point do code completion on 'sel'
                 so if this method is called it will treat 'sel as an extra child.
stroom-query/stroom-query-common/src/main/java/stroom/query/language/SearchRequestFactory.java