List<VirtualFile> (final Collection<? extends VirtualFile> files) { final List<VirtualFile> result = new ArrayList<>(); final LinkedList<VirtualFile> filesQueue = new LinkedList<>(files); while (!filesQueue.isEmpty()) { ProgressManager.checkCanceled(); final VirtualFile file = filesQueue.removeFirst(); if (file.isDirectory()) { filesQueue.addAll(Arrays.asList(file.getChildren())); continue; } if (PatchFileType.isPatchFile(file)) { result.add(file); } } return result; }