android/guava/src/com/google/common/collect/Iterables.java
private static <E> Collection<E> castOrCopyToCollection(Iterable<E> iterable) {
    return (iterable instanceof Collection)
        ? (Collection<E>) iterable
        : Lists.newArrayList(iterable.iterator());
  }
private static <E> Collection<E> castOrCopyToCollection(Iterable<E> iterable) {
    return (iterable instanceof Collection)
        ? (Collection<E>) iterable
        : Lists.newArrayList(iterable.iterator());
  }
Converts an iterable into a collection. If the iterable is already a collection, it is
returned. Otherwise, an {@link java.util.ArrayList} is created with the contents of the
iterable in the same iteration order.