List<PsiElement> (PsiElement element, @NotNull PyExpression expression) { if (isAssignedLocalVariable(element)) { PyFunction function = PsiTreeUtil.getParentOfType(element, PyFunction.class); Collection<PsiReference> references = ReferencesSearch.search(element, new LocalSearchScope(function)).findAll(); ArrayList<PsiElement> result = new ArrayList<>(); for (PsiReference reference : references) { PsiElement refElement = reference.getElement(); if (refElement != element) { result.add(refElement); } } return result; } return super.getOccurrences(element, expression); }