Iterable<File> (final File file, final boolean recursively) { final Iterable<File> childrenIterable = Iterators.lazy(new Iterators.Provider<Iterable<File>>() { @Override public Iterable<File> get() { final Iterable<File> children = listChildren(file); return children == null? Collections.<File>emptyList() : children; } }); return !recursively? childrenIterable : Iterators.flat(Iterators.map(childrenIterable, new Function<File, Iterable<File>>() { @Override public Iterable<File> fun(File ff) { return asRecursiveIterable(ff); } })); }