private static boolean expressionAssignsVariableOrFails(@Nullable PsiExpression expression, PsiVariable variable,
                                                          @NotNull Set<MethodSignature> checkedMethods, boolean strict) {
    if (expression == null) {
      return false;
    }
    if (expression instanceof PsiThisExpression ||
        expression instanceof PsiLiteralExpression ||
        expression instanceof PsiSuperExpression ||
        expression instanceof PsiClassObjectAccessExpression ||
        expression instanceof PsiReferenceExpression) {
      return false;
    }
    else if (expression instanceof PsiParenthesizedExpression parenthesizedExpression) {
      return expressionAssignsVariableOrFails(parenthesizedExpression.getExpression(), variable, checkedMethods, strict);
    }
    else if (expression instanceof PsiMethodCallExpression methodCallExpression) {
      return methodCallAssignsVariableOrFails(methodCallExpression, variable, checkedMethods, strict);
    }
    else if (expression instanceof PsiNewExpression newExpression) {
      return newExpressionAssignsVariableOrFails(newExpression, variable, checkedMethods, strict);
    }
    else if (expression instanceof PsiArrayInitializerExpression array) {
      for (final PsiExpression initializer : array.getInitializers()) {
        if (expressionAssignsVariableOrFails(initializer, variable, checkedMethods, strict)) {
          return true;
        }
      }
      return false;
    }
    else if (expression instanceof PsiTypeCastExpression typeCast) {
      return expressionAssignsVariableOrFails(typeCast.getOperand(), variable, checkedMethods, strict);
    }
    else if (expression instanceof PsiArrayAccessExpression accessExpression) {
      return expressionAssignsVariableOrFails(accessExpression.getArrayExpression(), variable, checkedMethods, strict) ||
             expressionAssignsVariableOrFails(accessExpression.getIndexExpression(), variable, checkedMethods, strict);
    }
    else if (expression instanceof PsiUnaryExpression unaryOperation) {
      return expressionAssignsVariableOrFails(unaryOperation.getOperand(), variable, checkedMethods, strict);
    }
    else if (expression instanceof PsiPolyadicExpression polyadicExpression) {
      for (PsiExpression operand : polyadicExpression.getOperands()) {
        if (expressionAssignsVariableOrFails(operand, variable, checkedMethods, strict)) {
          return true;
        }
      }
      return false;
    }
    else if (expression instanceof PsiConditionalExpression conditional) {
      if (expressionAssignsVariableOrFails(conditional.getCondition(), variable, checkedMethods, strict)) {
        return true;
      }
      return expressionAssignsVariableOrFails(conditional.getThenExpression(), variable, checkedMethods, strict) &&
             expressionAssignsVariableOrFails(conditional.getElseExpression(), variable, checkedMethods, strict);
    }
    else if (expression instanceof PsiAssignmentExpression assignment) {
      final PsiExpression lhs = assignment.getLExpression();
      if (expressionAssignsVariableOrFails(lhs, variable, checkedMethods, strict)) {
        return true;
      }
      if (expressionAssignsVariableOrFails(assignment.getRExpression(), variable, checkedMethods, strict)) {
        return true;
      }
      if (lhs instanceof PsiReferenceExpression) {
        final PsiElement element = ((PsiReference)lhs).resolve();
        return variable.equals(element);
      }
      return false;
    }
    else if (expression instanceof PsiInstanceOfExpression instanceOfExpression) {
      return expressionAssignsVariableOrFails(instanceOfExpression.getOperand(), variable, checkedMethods, strict);
    }
    else {
      return false;
    }
  }
private static boolean expressionAssignsVariableOrFails(@Nullable PsiExpression expression, PsiVariable variable,
                                                          @NotNull Set<MethodSignature> checkedMethods, boolean strict)