PsiExpression (@Nullable PsiExpression expression) { int preventEndlessLoop = 5; while (expression instanceof PsiReferenceExpression) { if (--preventEndlessLoop == 0) return null; expression = findVariableDefinition((PsiReferenceExpression)expression); } return expression; }