code: public static <T> List<T> asList(Iterator<T> itr) {
          List<T> l = new ArrayList<>();
          if (itr != null) {
              while (itr.hasNext()) {
                  l.add(itr.next());
              }
          }
          return l;
      }
docs: Returns an iterator as a list.
  
  @param itr
  an <code>Iterator</code>.
  @return a <code>List</code>.