private Item replaceOrItems(Item item, int hits) {
        if (!(item instanceof CompositeItem compositeItem)) {
            return item;
        }
        if (compositeItem instanceof OrItem) {
            WeakAndItem newItem = new WeakAndItem(hits);
            newItem.setWeight(compositeItem.getWeight());
            compositeItem.items().forEach(newItem::addItem);
            compositeItem = newItem;
        }
        for (int i = 0; i < compositeItem.getItemCount(); i++) {
            Item subItem = compositeItem.getItem(i);
            Item replacedItem = replaceOrItems(subItem, hits);
            if (replacedItem != subItem) {
                compositeItem.setItem(i, replacedItem);
            }
        }
        return compositeItem;
    }
Recursively iterates over an Item to replace all instances of OrItems with WeakAndItems
@param item the current item in the replacement iteration
@param hits the wand.hits property from the request which is assigned to the N value of the new WeakAndItem
@return the original item or a WeakAndItem replacement of an OrItem
container-search/src/main/java/com/yahoo/search/querytransform/WeakAndReplacementSearcher.java