PsiReferenceExpression (@NotNull PsiElement element, @NotNull PsiVariable variable) { final PsiReferenceExpression reference = findReferenceTo(element, variable); if (reference != null) return reference; while (element != null) { if (element instanceof PsiReferenceExpression) { return (PsiReferenceExpression)element; } if (element instanceof PsiMethod || element instanceof PsiClass) { return null; } element = element.getParent(); } return null; }