private void flatten(Item item,int position,List<FlattenedItem> toList) {
        if (item == null) return;
        if (item.isFilter()) return;

        if (item instanceof TermItem) {  // make eligible for matching
            toList.add(new FlattenedItem((TermItem)item, position));
            return;
        }

        if (item instanceof CompositeItem) { // make children eligible for matching
            CompositeItem composite = (CompositeItem)item;
            int childPosition = 0;
            for (Iterator<?> i = composite.getItemIterator(); i.hasNext(); ) {
                flatten((Item)i.next(), childPosition++, toList);
            }
        }

        // other terms are inmatchable
    }
A special purpose check used to simplify the above
container-search/src/main/java/com/yahoo/prelude/semantics/engine/Evaluation.java