UsageGroup (@NotNull Usage usage, UsageTarget @NotNull [] targets) { if (!(usage instanceof PsiElementUsage)) return null; final PsiElement psiElement = ((PsiElementUsage)usage).getElement(); final PyFunction pyFunction = PsiTreeUtil.getParentOfType(psiElement, PyFunction.class, false, PyClass.class); if (pyFunction != null) { return new PsiNamedElementUsageGroupBase<>(pyFunction); } return null; }