@Contract(pure=true)
  public static PsiElement @NotNull [] collectElements(@Nullable PsiElement element, @NotNull PsiElementFilter filter) {
    List<PsiElement> result = new ArrayList<>();
    processElements(element, e -> {
      if (filter.isAccepted(e)) result.add(e);
      return true;
    });
    return result.toArray(PsiElement.EMPTY_ARRAY);
  }
@Contract(pure=true)
  public static PsiElement @NotNull [] collectElements(@Nullable PsiElement element, @NotNull PsiElementFilter filter)