private static <T> void iterateDistinctPairs(final Iterator<T> it, IPairIteratorCallback<T> callback) {
        List<T> list = new ArrayList<>();
        while (it.hasNext()) {
            list.add(it.next());
        }


//        List<T> list = Convert.toMinimumArrayList(new Iterable<T>() {
//
//            @Override
//            public Iterator<T> iterator() {
//                return it;
//            }
//
//        });

        for (int outerIndex = 0; outerIndex < list.size() - 1; outerIndex++) {
            for (int innerIndex = outerIndex + 1; innerIndex < list.size(); innerIndex++) {
                callback.pair(list.get(outerIndex), list.get(innerIndex));
            }
        }
    }
Iterates through each distinct unordered pair formed by the elements of a given iterator
stroom-query/stroom-query-language/src/test/java/stroom/query/language/functions/CheckComparator.java