void (List<? super File> container, File from, String relativePath, final AntDomPattern pattern) { if (myDirsProcessed > MAX_DIRS_TO_PROCESS) { return; } myDirsProcessed++; final File[] children = from.listFiles(); if (children != null) { for (File child : children) { if (child.isDirectory()) { final String childPath = makePath(relativePath, child.getName()); if (pattern.acceptPath(childPath)) { container.add(child); } if (pattern.couldBeIncluded(childPath)) { collectFiles(container, child, childPath, pattern); } } } } }