PsiReferenceExpression (@NotNull PsiElement element, @NotNull PsiVariable variable) { if (element instanceof PsiReferenceExpression && ExpressionUtil.isEffectivelyUnqualified((PsiReferenceExpression)element) && ((PsiReferenceExpression)element).isReferenceTo(variable)) { return (PsiReferenceExpression)element; } for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) { final PsiReferenceExpression reference = findReferenceTo(child, variable); if (reference != null) return reference; } return null; }