code: public static <E> Set<E> copyOf(Iterator<? extends E> elementsIterator) {
      Set<E> result = new HashSet<>();
      while (elementsIterator.hasNext()) {
        result.add(elementsIterator.next());
      }
      return Collections.unmodifiableSet(result);
    }
docs: Returns an unmodifiable view of the set created from the given elements.
  
  @param elementsIterator iterator to get the elements of the set.
  @param <E>              type of the elements
  @return an unmodifiable view of the set created from the given elements.