private int stackDepth(int i, Item root) {
        if (root instanceof CompositeItem) {
            int maxDepth = i;

            for (Iterator<Item> j = ((CompositeItem) root).getItemIterator(); j.hasNext();) {
                int newDepth = stackDepth(i + 1, j.next());

                maxDepth = java.lang.Math.max(maxDepth, newDepth);
            }
            return maxDepth;
        } else {
            return i;
        }
    }
Various tests for prefix, substring, and suffix terms *
container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java