public static void collapseSingleComposites(Query query) {
        Item oldRoot = query.getModel().getQueryTree().getRoot();
        Item newRoot = collapseSingleComposites(oldRoot);
        if (oldRoot != newRoot) {
            query.getModel().getQueryTree().setRoot(newRoot);
        }
    }
Collapses all single-child {@link CompositeItem}s into their parent item.
container-search/src/main/java/com/yahoo/prelude/querytransform/QueryRewrite.java