private static boolean scanCatches(@NotNull PsiElement elem,
                                     @NotNull Processor<? super UsageInfo> processor,
                                     @NotNull Root root,
                                     @NotNull FindUsagesOptions options,
                                     @NotNull Set<? super PsiMethod> processed) {
    while (elem != null) {
      final PsiElement parent = elem.getParent();
      if (elem instanceof PsiMethod) {
        final PsiMethod deepestSuperMethod = ((PsiMethod)elem).findDeepestSuperMethod();
        final PsiMethod method = deepestSuperMethod != null ? deepestSuperMethod : (PsiMethod)elem;
        if (!processed.contains(method)) {
          processed.add(method);
          final PsiReference[] refs = MethodReferencesSearch.search(method, options.searchScope, true).toArray(PsiReference.EMPTY_ARRAY);
          for (int i = 0; i != refs.length; ++i) {
            if (!scanCatches(refs[i].getElement(), processor, root, options, processed)) return false;
          }
        }
        return true;
      }
      if (elem instanceof PsiTryStatement aTry) {
        final PsiParameter[] catches = aTry.getCatchBlockParameters();
        for (int i = 0; i != catches.length; ++i) {
          if (!processExn(catches[i], processor, root)) {
            return false;
          }
        }
      }
      else if (parent instanceof PsiTryStatement tryStmt) {
        if (elem != tryStmt.getTryBlock()) {
          elem = parent.getParent();
          continue;
        }
      }
      elem = parent;
    }
    return true;
  }
private static boolean scanCatches(@NotNull PsiElement elem,
                                     @NotNull Processor<? super UsageInfo> processor,
                                     @NotNull Root root,
                                     @NotNull FindUsagesOptions options,
                                     @NotNull Set<? super PsiMethod> processed)