private static boolean canBeMutated(@NotNull PsiExpression expr) {
    while (expr.getParent() instanceof PsiParenthesizedExpression parent) {
      expr = parent;
    }
    if (isVoidContext(expr)) return false;
    if (PsiUtil.isAccessedForWriting(expr)) return true;
    PsiElement parent = expr.getParent();
    if (parent instanceof PsiForeachStatement forEach && PsiTreeUtil.isAncestor(forEach.getIteratedValue(), expr, false)) {
      return false;
    }
    if (parent instanceof PsiReferenceExpression refParent) {
      if (getArrayFromLengthExpression(refParent) != null) return false;
      if (parent.getParent() instanceof PsiMethodCallExpression call &&
          MethodCallUtils.isCallToMethod(
            call, JAVA_LANG_OBJECT, null, "clone", PsiType.EMPTY_ARRAY)) {
        return false;
      }
    }
    if (parent instanceof PsiExpressionList list && list.getParent() instanceof PsiMethodCallExpression call) {
      PsiMethod method = call.resolveMethod();
      if (method == null) return true;
      MutationSignature signature = MutationSignature.fromCall(call);
      if (!signature.isPure()) return true;
      PsiType type = method.getReturnType();
      if (type instanceof PsiPrimitiveType || TypeUtils.isJavaLangString(type)) return false;
      return canBeMutated(call);
    }
    if (parent instanceof PsiLocalVariable variable) {
      return !isConstantContent(variable);
    }
    if (parent instanceof PsiArrayAccessExpression arrayAccess) {
      return PsiUtil.isAccessedForWriting(arrayAccess);
    }
    return true;
  }
private static boolean canBeMutated(@NotNull PsiExpression expr)