docs: public static <T> Set<T> iteratorToSet(Iterator<T> iterator) {
          Set<T> set = new HashSet<>();
          while (iterator.hasNext()) {
              set.add(iterator.next());
          }
          return set;
      }