code: public static <T> Iterator<T> removeDups(Iterator<T> iterator) {
          return new FilterIterator<T>(iterator) {
              final Set<T> found = new HashSet<>();
              @Override
              protected boolean filter(T t) {
                  return found.add(t);
              }
          };
      }
docs: Filters another iterator by eliminating duplicates.