private void markAllTermsAsFilters(Item root) {
        if (root instanceof BlockItem) {
            root.setFilter(true);
        }

        if (root instanceof TermItem) {
            root.setFilter(true);
        } else {
            if (root instanceof PhraseItem) {
                root.setFilter(true);
            }
            if (root instanceof CompositeItem composite) {
                for (Iterator<Item> i = composite.getItemIterator(); i.hasNext(); ) {
                    markAllTermsAsFilters(i.next());
                }
            }
        }
    }
Returns the top level item resulting from combining the given top
level item and the new item. This implements most of the weird transformation
rules of the parser.
container-search/src/main/java/com/yahoo/prelude/query/parser/AnyParser.java