private static void processImplicitPackageMembers(@NotNull PsiFileSystemItem anchor,
                                                    @Nullable PsiElement location,
                                                    @Nullable PyImportedModule importedModule,
                                                    @NotNull Predicate<String> filter,
                                                    @NotNull Processor<List<? extends RatedResolveResult>> resultProcessor) {
    final List<PyImportElement> importElements = new ArrayList<>();
    final PyFile module = PyUtil.as(PyUtil.turnDirIntoInit(anchor), PyFile.class);
    if (anchor.getVirtualFile() == null) {
      return;
    }
    final PsiElement footHold = location != null ? location.getContainingFile() : module;
    if (footHold == null) {
      return;
    }
    final PyImportElement origImportElement = importedModule != null ? importedModule.getImportElement() : null;
    if (importedModule != null && (location == null || !inSameFile(location, importedModule))) {
      if (origImportElement != null) {
        importElements.add(origImportElement);
      }
    }
    else if (location != null) {
      final ScopeOwner owner = ScopeUtil.getScopeOwner(location);
      if (owner != null) {
        importElements.addAll(getVisibleImports(owner));
      }

      if (module != null) {
        if (!inSameFile(location, module)) {
          importElements.addAll(module.getImportTargets());
        }
        final List<PyFromImportStatement> imports = module.getFromImports();
        for (PyFromImportStatement anImport : imports) {
          Collections.addAll(importElements, anImport.getImportElements());
        }
      }
    }

    if (importElements.isEmpty()) {
      return;
    }

    final Set<String> seen = new HashSet<>();
    if (!processImplicitlyImportedByImportElements(anchor, footHold,
                                                   importElements, name -> filter.test(name) && seen.add(name),
                                                   resultProcessor)) {
      return;
    }

    if (location != null) {
      processImplicitlyImportedByLocation(anchor, location,
                                          name -> filter.test(name) && seen.add(name),
                                          resultProcessor);
    }
  }
private static void processImplicitPackageMembers(@NotNull PsiFileSystemItem anchor,
                                                    @Nullable PsiElement location,
                                                    @Nullable PyImportedModule importedModule,
                                                    @NotNull Predicate<String> filter,
                                                    @NotNull Processor<List<? extends RatedResolveResult>> resultProcessor)