JBIterable<VirtualFile> (@NotNull VcsTreeModelData data) { return data.iterateUserObjects() .flatMap(entry -> { if (entry instanceof Change) { return ChangesUtil.iteratePathsCaseSensitive((Change)entry) .map(FilePath::getVirtualFile); } else if (entry instanceof VirtualFile) { return JBIterable.of((VirtualFile)entry); } else if (entry instanceof FilePath) { return JBIterable.of(((FilePath)entry).getVirtualFile()); } return JBIterable.empty(); }) .filterNotNull() .filter(VirtualFile::isValid); }