public static @NotNull <T> HashSet<T> newHashSet(@NotNull Iterator<? extends T> iterator) {
    HashSet<T> set = new HashSet<>();
    while (iterator.hasNext()) set.add(iterator.next());
    return set;
  }
public static @NotNull <T> HashSet<T> newHashSet(@NotNull Iterator<? extends T> iterator)