private static @Nullable PsiVariable findVariableAssignedTo(@NotNull PsiExpression occurrence) {
      PsiElement parent = PsiUtil.skipParenthesizedExprUp(occurrence);
      PsiElement context = PsiTreeUtil.getParentOfType(parent, PsiVariable.class, PsiAssignmentExpression.class);
      PsiVariable variable = ObjectUtils.tryCast(context, PsiVariable.class);
      if (variable != null) {
        if (variable.getInitializer() != parent) return null;
        return variable;
      }
      if (context == null) return null;
      PsiAssignmentExpression assignment = (PsiAssignmentExpression)context;
      if (assignment.getRExpression() != parent) return null;
      PsiReferenceExpression ref = ObjectUtils.tryCast(assignment.getLExpression(), PsiReferenceExpression.class);
      if (ref == null) return null;
      PsiVariable target = ObjectUtils.tryCast(ref.resolve(), PsiVariable.class);
      if (!PsiUtil.isJvmLocalVariable(target)) return null;
      return target;
    }
private static @Nullable PsiVariable findVariableAssignedTo(@NotNull PsiExpression occurrence)