List<RatedResolveResult> (@NotNull PyFile parent, @NotNull String referencedName, @Nullable PsiFile containingFile, boolean fileOnly, boolean checkForPackage, boolean withoutStubs, boolean withoutForeign) { final List<RatedResolveResult> moduleMembers = resolveModuleMember(parent, referencedName); final List<RatedResolveResult> resolvedInModule = new ArrayList<>(); final List<RatedResolveResult> results = new ArrayList<>(); for (RatedResolveResult member : moduleMembers) { final PsiElement moduleMember = member.getElement(); if (!fileOnly || PsiTreeUtil.instanceOf(moduleMember, PsiFile.class, PsiDirectory.class)) { results.add(member); if (moduleMember != null && !preferResolveInDirectoryOverModule(moduleMember)) { resolvedInModule.add(member); } } } if (!resolvedInModule.isEmpty()) { return resolvedInModule; } final List<RatedResolveResult> resolvedInDirectory = resolveInPackageDirectory(parent, referencedName, containingFile, fileOnly, checkForPackage, withoutStubs, withoutForeign); if (!resolvedInDirectory.isEmpty()) { return resolvedInDirectory; } return results; }