@NotNull
  private static List<RatedResolveResult> resolveInDirectory(@NotNull final String referencedName,
                                                             @Nullable final PsiFile containingFile,
                                                             final PsiDirectory dir,
                                                             boolean isFileOnly,
                                                             boolean checkForPackage,
                                                             boolean withoutStubs) {
    final ResolveResultList result = new ResolveResultList();

    final PsiDirectory subdir = dir.findSubdirectory(referencedName);
    // VFS may be case insensitive on Windows, but resolve is always case sensitive (PEP 235, PY-18958), so we check name here
    if (subdir != null && subdir.getName().equals(referencedName) &&
        (!checkForPackage || PyUtil.isPackage(subdir, containingFile)) &&
        (!withoutStubs || PyUtil.isOrdinaryPackage(subdir) || !PyiUtil.isPyiFileOfPackage(subdir))) {
      result.add(new RatedResolveResult(RatedResolveResult.RATE_NORMAL, PyStubPackages.transferStubPackageMarker(dir, subdir)));
    }

    final PsiDirectory stubPackage = PyStubPackages.findStubPackage(dir, referencedName, checkForPackage, withoutStubs);
    if (stubPackage != null) {
      result.add(new RatedResolveResult(RatedResolveResult.RATE_NORMAL, stubPackage));
    }

    final PsiFile module = findPyFileInDir(dir, referencedName, withoutStubs);
    if (module != null) {
      result.add(new RatedResolveResult(RatedResolveResult.RATE_NORMAL, PyStubPackages.transferStubPackageMarker(dir, module)));
    }

    if (!isFileOnly) {
      final PsiElement packageElement = PyUtil.getPackageElement(dir, containingFile);
      if (packageElement != containingFile && packageElement instanceof PyFile) {
        result.addAll(((PyFile)packageElement).multiResolveName(referencedName));
      }
    }

    return result;
  }
@NotNull
  private static List<RatedResolveResult> resolveInDirectory(@NotNull final String referencedName,
                                                             @Nullable final PsiFile containingFile,
                                                             final PsiDirectory dir,
                                                             boolean isFileOnly,
                                                             boolean checkForPackage,
                                                             boolean withoutStubs)