code: public static <T> Iterator<T> cycle(final Iterable<T> iterable) {
      checkNotNull(iterable);
      return new Iterator<T>() {
        Iterator<T> iterator = emptyIterator();
        Iterator<T> removeFrom;
  
        @Override
        public boolean hasNext() {
          if (!iterator.hasNext()) {
            iterator = iterable.iterator();
          }
          return iterator.hasNext();
        }
        @Override
        public T next() {
          if (!hasNext()) {
            throw new NoSuchElementException();
          }
          removeFrom = iterator;
          return iterator.next();
        }
        @Override
        public void remove() {
          checkRemove(removeFrom != null);
          removeFrom.remove();
          removeFrom = null;
        }
      };
    }
docs: Returns an iterator that cycles indefinitely over the elements of {@code
  iterable}.
  
  <p>The returned iterator supports {@code remove()} if the provided iterator
  does. After {@code remove()} is called, subsequent cycles omit the removed
  element, which is no longer in {@code iterable}. The iterator's
  {@code hasNext()} method returns {@code true} until {@code iterable} is
  empty.
  
  <p><b>Warning:</b> Typical uses of the resulting iterator may produce an
  infinite loop. You should use an explicit {@code break} or be certain that
  you will eventually remove all the elements.