private static void processImplicitlyImportedByLocation(@NotNull PsiFileSystemItem anchor,
                                                          @NotNull PsiElement location,
                                                          @NotNull Predicate<String> filter,
                                                          @NotNull Processor<List<? extends RatedResolveResult>> resultProcessor) {

    if (location.getContainingFile().getVirtualFile() == null) {
      return;
    }
    final ScopeOwner owner = ScopeUtil.getScopeOwner(location);
    if (owner == null) {
      return;
    }

    final List<PyImportElement> visibleImports = getVisibleImports(owner);
    final PyFile module = PyUtil.as(PyUtil.turnDirIntoInit(anchor), PyFile.class);
    final List<QualifiedName> packageQNames =
      QualifiedNameFinder.findImportableQNames(location.getContainingFile(), anchor.getVirtualFile());
    final List<QualifiedName> locationQNames =
      QualifiedNameFinder.findImportableQNames(location, location.getContainingFile().getVirtualFile());
    for (QualifiedName locationQName : locationQNames) {
      for (QualifiedName packageQName : packageQNames) {
        final String directChild = findFirstComponentAfterPrefix(locationQName, packageQName);
        if (directChild != null && filter.test(directChild)) {
          final QualifiedName mainPackage = QualifiedName.fromComponents(locationQName.getFirstComponent());
          final PyImportElement packageImportElement =
            visibleImports.stream().filter(el -> getImportedQNames(el).stream().anyMatch(qName -> qName.matchesPrefix(mainPackage)))
                          .findFirst().orElse(null);

          if (packageImportElement != null) {
            final List<RatedResolveResult> results =
              ResolveImportUtil.resolveChildren(anchor, directChild, module, true, true, false, false);
            if (!resultProcessor.process(ResolveResultList.asImportedResults(results, packageImportElement))) {
              return;
            }
          }
        }
      }
    }
  }
private static void processImplicitlyImportedByLocation(@NotNull PsiFileSystemItem anchor,
                                                          @NotNull PsiElement location,
                                                          @NotNull Predicate<String> filter,
                                                          @NotNull Processor<List<? extends RatedResolveResult>> resultProcessor)