Iterable<File> (final File file) { return Iterators.flat(Iterators.map(Iterators.asIterable(file), new Function<File, Iterable<File>>() { @Override public Iterable<File> fun(File f) { final Iterable<File> children = listChildren(f); if (children == null) { // not a dir return Iterators.asIterable(f); } if (Iterators.isEmptyCollection(children)) { return children; } return Iterators.flat(Iterators.map(children, new Function<File, Iterable<File>>() { @Override public Iterable<File> fun(File ff) { return asRecursiveIterable(ff); } })); } })); }