private static @NotNull List<SwitchBranch> rearrangeBranches(@NotNull List<SwitchBranch> branches,
                                                      @NotNull PsiElement context) {
    if (branches.isEmpty()) {
      return branches;
    }
    if (!PsiUtil.isAvailable(JavaFeature.PATTERNS_IN_SWITCH, context)) {
      return branches;
    }
    List<SwitchBranch> result = new ArrayList<>();
    for (SwitchBranch branch : branches) {
      if (branch.myIsDefault) {
        result.add(branch);
        continue;
      }
      List<? extends PsiCaseLabelElement> caseExpressions = branch.myCaseExpressions;
      if (caseExpressions == null || caseExpressions.size() <= 1) {
        result.add(branch);
        continue;
      }
      rearrangeCases(branch, caseExpressions, result);
    }
    return result;
  }
private static @NotNull List<SwitchBranch> rearrangeBranches(@NotNull List<SwitchBranch> branches,
                                                      @NotNull PsiElement context)