private static void collectCallees(@NotNull PsiElement element, @NotNull List<? super PsiMethod> methods) {
    PsiElement[] children = element.getChildren();
    for (PsiElement child : children) {
      collectCallees(child, methods);
      if (child instanceof PsiMethodCallExpression callExpression) {
        PsiReferenceExpression methodExpression = callExpression.getMethodExpression();
        PsiMethod method = (PsiMethod)methodExpression.resolve();
        if (method != null) {
          methods.add(method);
        }
      }
      else if (child instanceof PsiNewExpression newExpression) {
        PsiMethod method = newExpression.resolveConstructor();
        if (method != null) {
          methods.add(method);
        }
      }
      else if (child instanceof PsiMethodReferenceExpression methodRef && methodRef.resolve() instanceof PsiMethod method) {
        methods.add(method);
      }
    }
  }
private static void collectCallees(@NotNull PsiElement element, @NotNull List<? super PsiMethod> methods)