public static @Nullable PsiMethod tryGetMethodFromCandidate(@NotNull Object object) {
    return object instanceof CandidateWithPresentation cwp ? cwp.getMethod() : null;
  }
public static @Nullable PsiMethod tryGetMethodFromCandidate(@NotNull Object object)