public Hit next() throws NoSuchElementException {
        if (hits.size() <= (index + 1)) {
            throw new NoSuchElementException();
        } else {
            canRemove = true;
            return hits.get(++index);
        }
    }
Whether the iterator is in a state where remove is OK
container-search/src/main/java/com/yahoo/search/result/HitIterator.java