private static @Nullable PsiExpression findSelectorWithComparedPrimitives(@NotNull PsiPolyadicExpression expression) {
    if (!PsiUtil.isAvailable(JavaFeature.PRIMITIVE_TYPES_IN_PATTERNS, expression)) {
      return null;
    }
    IElementType operationTokenType = expression.getOperationTokenType();
    List<PsiBinaryExpression> binaryExpressions = new ArrayList<>();
    if (operationTokenType == JavaTokenType.OROR || operationTokenType == JavaTokenType.ANDAND) {
      for (PsiExpression operand : expression.getOperands()) {
        if (operand instanceof PsiBinaryExpression psiBinaryExpression) {
          binaryExpressions.add(psiBinaryExpression);
        }
        else {
          return null;
        }
      }
    }
    else if (expression instanceof PsiBinaryExpression binaryExpression) {
      binaryExpressions.add(binaryExpression);
    }
    else {
      return null;
    }
    PsiExpression switchSelector = null;
    for (PsiBinaryExpression binaryExpression : binaryExpressions) {
      IElementType binaryExpressionOperationTokenType = binaryExpression.getOperationTokenType();
      if (JavaTokenType.LE.equals(binaryExpressionOperationTokenType) ||
          JavaTokenType.LT.equals(binaryExpressionOperationTokenType) ||
          JavaTokenType.GE.equals(binaryExpressionOperationTokenType) ||
          JavaTokenType.GT.equals(binaryExpressionOperationTokenType)) {
        PsiExpression lOperand = binaryExpression.getLOperand();
        PsiExpression rOperand = binaryExpression.getROperand();
        EquivalenceChecker equivalence = EquivalenceChecker.getCanonicalPsiEquivalence();
        if (lOperand instanceof PsiReferenceExpression referenceExpression && referenceExpression.resolve() instanceof PsiVariable &&
            ExpressionUtils.computeConstantExpression(rOperand) != null) {
          if (switchSelector != null && !equivalence.expressionsAreEquivalent(switchSelector, lOperand)) {
            return null;
          }
          switchSelector = lOperand;
        }
        else if (rOperand instanceof PsiReferenceExpression referenceExpression && referenceExpression.resolve() instanceof PsiVariable &&
                 ExpressionUtils.computeConstantExpression(lOperand) != null) {
          if (switchSelector != null && !equivalence.expressionsAreEquivalent(switchSelector, rOperand)) {
            return null;
          }
          switchSelector = rOperand;
        }
      }
    }
    if (switchSelector == null) {
      return null;
    }
    PsiType switchSelectorType = switchSelector.getType();
    if (switchSelectorType == null || !TypeConversionUtil.isPrimitiveAndNotNullOrWrapper(switchSelectorType)) {
      return null;
    }
    return switchSelector;
  }
private static @Nullable PsiExpression findSelectorWithComparedPrimitives(@NotNull PsiPolyadicExpression expression)