PsiElement (@NotNull final PsiElement sourceElement) { for (final PsiReference reference : sourceElement.getReferences()) { if (reference instanceof PyUserInitiatedResolvableReference) { final PsiElement element = ((PyUserInitiatedResolvableReference)reference).userInitiatedResolve(); if (element != null && element != sourceElement) { return element; } } } return null; }