private void addTopLevelRankTerms(RankItem rankTerms, Query query) {
        Item root = query.getModel().getQueryTree().getRoot();
        if (root instanceof RankItem) {
            for (Iterator<Item> i = rankTerms.getItemIterator(); i.hasNext(); ) {
                ((RankItem)root).addItem(i.next());
            }
        }
        else {
            rankTerms.addItem(0, root);
            query.getModel().getQueryTree().setRoot(rankTerms);

        }
    }
Adds a RankItem at the root of a query, but only if there is
at least one rank term in the specified RankItem.
If the root is already a RankItem, just append the new rank terms.

@param rankTerms the new rank item to add.
@param query the query to add to
container-search/src/main/java/com/yahoo/prelude/querytransform/LiteralBoostSearcher.java