public static List<PsiCaseLabelElement> findRemovableUnreachableBranches(PsiCaseLabelElement reachableLabel,
                                                                           PsiSwitchBlock statement) {
    PsiSwitchLabelStatementBase labelStatement = PsiTreeUtil.getParentOfType(reachableLabel, PsiSwitchLabelStatementBase.class);
    List<PsiSwitchLabelStatementBase> allBranches =
      PsiTreeUtil.getChildrenOfTypeAsList(statement.getBody(), PsiSwitchLabelStatementBase.class);
    boolean hasDefault = false;
    List<PsiCaseLabelElement> unreachableElements = new ArrayList<>();
    for (PsiSwitchLabelStatementBase branch : allBranches) {
      if (branch.isDefaultCase()) {
        hasDefault = true;
        continue;
      }
      PsiCaseLabelElementList elementList = branch.getCaseLabelElementList();
      if (elementList == null) {
        continue;
      }
      PsiCaseLabelElement[] elements = elementList.getElements();
      unreachableElements.addAll(Arrays.asList(elements));
    }
    unreachableElements.remove(reachableLabel);
    boolean canUnwrap = (statement instanceof PsiSwitchStatement && BreakConverter.from(statement) != null) ||
                        (statement instanceof PsiSwitchExpression &&
                         labelStatement instanceof PsiSwitchLabeledRuleStatement ruleStatement &&
                         ruleStatement.getBody() instanceof PsiExpressionStatement);
    if (canUnwrap) {
      return unreachableElements;
    }

    if (unreachableElements.isEmpty() || hasDefault) {
      return unreachableElements;
    }
    boolean isEnhancedSwitch = JavaPsiSwitchUtil.isEnhancedSwitch(statement);
    if (isEnhancedSwitch) {
      PsiExpression expression = statement.getExpression();
      if (expression == null) {
        return List.of();
      }
      PsiType selectorType = expression.getType();
      if (selectorType == null) {
        return List.of();
      }
      List<PsiCaseLabelElement> toDelete = new ArrayList<>();
      for (int i = 0; i < unreachableElements.size(); i++) {
        PsiCaseLabelElement currentElement = unreachableElements.get(i);
        boolean isDominated = false;
        for (int j = i + 1; j < unreachableElements.size(); j++) {
          PsiCaseLabelElement nextElement = unreachableElements.get(j);
          isDominated = PatternsInSwitchBlockHighlightingModel.isDominated(currentElement, nextElement, selectorType);
          if (!isDominated) {
            break;
          }
        }

        if (!isDominated) {
          toDelete.add(currentElement);
        }
      }
      unreachableElements.removeAll(toDelete);
    }
    return unreachableElements;
  }
public static List<PsiCaseLabelElement> findRemovableUnreachableBranches(PsiCaseLabelElement reachableLabel,
                                                                           PsiSwitchBlock statement)