public static boolean canBeSwitchCase(@Nullable PsiExpression expression,
                                        @NotNull PsiExpression switchExpression,
                                        @NotNull LanguageLevel languageLevel,
                                        @NotNull Set<Object> existingCaseValues,
                                        boolean isPatternMatch) {
    if (expression == null) return false;
    expression = PsiUtil.skipParenthesizedExprDown(expression);
    boolean primitiveTypesInPatternsSufficient = JavaFeature.PRIMITIVE_TYPES_IN_PATTERNS.isSufficient(languageLevel);
    if (isPatternMatch || primitiveTypesInPatternsSufficient) {
      boolean patternSwitchCase = canBePatternSwitchCase(expression, switchExpression, existingCaseValues);
      if (patternSwitchCase) return true;
      if (!primitiveTypesInPatternsSufficient) return false;
    }
    final EqualityCheck check = EqualityCheck.from(expression);
    if (check != null) {
      final PsiExpression left = check.getLeft();
      final PsiExpression right = check.getRight();
      if (canBeCaseLabel(left, languageLevel, existingCaseValues)) {
        return EquivalenceChecker.getCanonicalPsiEquivalence().expressionsAreEquivalent(switchExpression, right);
      }
      else if (canBeCaseLabel(right, languageLevel, existingCaseValues)) {
        return EquivalenceChecker.getCanonicalPsiEquivalence().expressionsAreEquivalent(switchExpression, left);
      }
    }
    if (primitiveTypesInPatternsSufficient && isComparisonWithPrimitives(expression, switchExpression, existingCaseValues)) {
      return true;
    }
    if (!(expression instanceof PsiPolyadicExpression polyadicExpression)) {
      return false;
    }
    final IElementType operation = polyadicExpression.getOperationTokenType();
    final PsiExpression[] operands = polyadicExpression.getOperands();
    if (operation.equals(JavaTokenType.OROR)) {
      for (PsiExpression operand : operands) {
        if (!canBeSwitchCase(operand, switchExpression, languageLevel, existingCaseValues, false)) {
          return false;
        }
      }
      return true;
    }
    else if (operation.equals(JavaTokenType.EQEQ) && operands.length == 2) {
      return (canBeCaseLabel(operands[0], languageLevel, existingCaseValues) &&
              !isExtendedPrimitives(PsiPrimitiveType.getOptionallyUnboxedType(operands[1].getType())) &&
              EquivalenceChecker.getCanonicalPsiEquivalence().expressionsAreEquivalent(switchExpression, operands[1])) ||
             (canBeCaseLabel(operands[1], languageLevel, existingCaseValues) &&
              !isExtendedPrimitives(PsiPrimitiveType.getOptionallyUnboxedType(operands[0].getType())) &&
              EquivalenceChecker.getCanonicalPsiEquivalence().expressionsAreEquivalent(switchExpression, operands[0]));
    }
    else {
      return false;
    }
  }
public static boolean canBeSwitchCase(@Nullable PsiExpression expression,
                                        @NotNull PsiExpression switchExpression,
                                        @NotNull LanguageLevel languageLevel,
                                        @NotNull Set<Object> existingCaseValues,
                                        boolean isPatternMatch)