@NotNull
  private static <E extends ResolveResult> Stream<E> takeOverloadsOtherwiseImplementations(@NotNull List<E> elements,
                                                                                           @NotNull Function<? super E, PsiElement> mapper,
                                                                                           @NotNull TypeEvalContext context) {
    if (!containsOverloadsAndImplementations(elements, mapper, context)) {
      return elements.stream();
    }

    return elements
      .stream()
      .filter(
        element -> {
          final PsiElement mapped = mapper.apply(element);
          return mapped != null && (PyiUtil.isInsideStub(mapped) || PyiUtil.isOverload(mapped, context));
        }
      );
  }
@NotNull
  private static <E extends ResolveResult> Stream<E> takeOverloadsOtherwiseImplementations(@NotNull List<E> elements,
                                                                                           @NotNull Function<? super E, PsiElement> mapper,
                                                                                           @NotNull TypeEvalContext context)