List<PsiFileSystemItem> (@Nullable PsiDirectory directory, @Nullable PsiElement anchor) { final List<PsiFileSystemItem> result = new ArrayList<>(); if (directory != null) { // just in case // file modules for (PsiFile f : directory.getFiles()) { final String filename = f.getName(); // if we have a binary module, we'll most likely also have a stub for it in site-packages if (!isExcluded(f) && (f instanceof PyFile && !filename.equals(PyNames.INIT_DOT_PY)) || isBinaryModule(filename)) { result.add(f); } } // dir modules for (PsiDirectory dir : directory.getSubdirectories()) { if (!isExcluded(dir) && PyUtil.isPackage(dir, anchor)) { result.add(dir); } } } return result; }