code: public static <T> List<T> toList(Iterator<T> self) {
          List<T> answer = new ArrayList<T>();
          while (self.hasNext()) {
              answer.add(self.next());
          }
          return answer;
      }
docs: Convert an iterator to a List. The iterator will become
  exhausted of elements after making this conversion.
  
  @param self an iterator
  @return a List
  @since 1.5.0