public static Collection asCollection(final Object iterable) {
        if (iterable instanceof Collection) {
            return (Collection) iterable;
        } else if ((iterable != null && iterable.getClass().isArray()) || iterable instanceof Iterable) {
            return (Collection) IteratorUtils.asList(iterable);
        } else {
            return null;
        }
    }
Turn an iterable type into a collection. Doesn't wrap any non-iterable type into an iterable (e.g. single Object
into list), but will transform one iterable type to another (e.g. array to list).

@param iterable an Iterable or array.
@return The iterable type as a Collection or null if argument isn't iterable.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/ListFunction.java