private static PsiExpression getPossibleSwitchSelectorExpression(PsiExpression expression, LanguageLevel languageLevel) {
    expression = PsiUtil.skipParenthesizedExprDown(expression);
    if (expression == null) {
      return null;
    }
    final EqualityCheck check = EqualityCheck.from(expression);
    if (check != null) {
      final PsiExpression left = check.getLeft();
      final PsiExpression right = check.getRight();
      if (canBeCaseLabel(left, languageLevel, null)) {
        return right;
      }
      else if (canBeCaseLabel(right, languageLevel, null)) {
        return left;
      }
    }
    if (PsiUtil.isAvailable(JavaFeature.PATTERNS_IN_SWITCH, expression)) {
      final PsiExpression patternSwitchExpression = findPatternSwitchExpression(expression);
      if (patternSwitchExpression != null) return patternSwitchExpression;
    }
    if (!(expression instanceof PsiPolyadicExpression polyadicExpression)) {
      return null;
    }
    final IElementType operation = polyadicExpression.getOperationTokenType();
    final PsiExpression[] operands = polyadicExpression.getOperands();
    if (operation.equals(JavaTokenType.OROR) && operands.length > 0) {
      return getPossibleSwitchSelectorExpression(operands[0], languageLevel);
    }
    else if (operation.equals(JavaTokenType.EQEQ) && operands.length == 2) {
      final PsiExpression lhs = PsiUtil.skipParenthesizedExprDown(operands[0]);
      final PsiExpression rhs = PsiUtil.skipParenthesizedExprDown(operands[1]);
      if (canBeCaseLabel(lhs, languageLevel, null)) {
        return rhs;
      }
      else if (canBeCaseLabel(rhs, languageLevel, null)) {
        return lhs;
      }
    }
    if (JavaFeature.PRIMITIVE_TYPES_IN_PATTERNS.isSufficient(languageLevel) &&
        expression instanceof PsiBinaryExpression psiBinaryExpression) {
      IElementType operationTokenType = psiBinaryExpression.getOperationTokenType();
      if (!operationTokenType.equals(JavaTokenType.EQEQ) &&
          !operationTokenType.equals(JavaTokenType.GT) &&
          !operationTokenType.equals(JavaTokenType.GE) &&
          !operationTokenType.equals(JavaTokenType.LT) &&
          !operationTokenType.equals(JavaTokenType.LE)) {
        return null;
      }
      final PsiExpression left = psiBinaryExpression.getLOperand();
      final PsiExpression right = psiBinaryExpression.getROperand();
      if (primitiveValueCanBeUsedForComparisonInCase(left, right, null)) {
        return right;
      }
      else if (primitiveValueCanBeUsedForComparisonInCase(right, left, null)) {
        return left;
      }
    }
    return null;
  }
private static PsiExpression getPossibleSwitchSelectorExpression(PsiExpression expression, LanguageLevel languageLevel)