List<SwitchBranch> (@NotNull List<SwitchBranch> branches, @NotNull PsiElement context) { if (branches.isEmpty()) { return branches; } boolean java20plus = PsiUtil.getLanguageLevel(context).isAtLeast(LanguageLevel.JDK_20_PREVIEW); if (!java20plus) { 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; }