Iterable<File> (File file) { if (!myDirectoryCache.isEmpty()) { File parent = file.getParentFile(); for (int i = 0; i < 10 && parent != null; i++) { // at most 10 levels upwards final Iterable<File> cached = myDirectoryCache.get(parent); if (cached != null) { return cached; } parent = parent.getParentFile(); } } return null; }