@Override
    protected Iterator<E> flatMap(final Traverser.Admin<S> traverser) {
        final S s = traverser.get();
        if (s instanceof Iterator)
            return (Iterator) s;
        else if (s instanceof Iterable)
            return ((Iterable) s).iterator();
        else if (s instanceof Map)
            return ((Map) s).entrySet().iterator();
        else if (s.getClass().isArray())
            return handleArrays(s);
        else
            return IteratorUtils.of((E) s);
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/UnfoldStep.java