PsiElement (@NotNull PsiSwitchLabelStatement labelStatement) { Branch branch = Branch.fromLabel(labelStatement); if (branch == null) { return null; } List<PsiSwitchLabelStatement> newLabels = new ArrayList<>(); PsiCaseLabelElement[] caseLabelElements = Objects.requireNonNull(labelStatement.getCaseLabelElementList()).getElements(); for (int i = caseLabelElements.length - 1; i >= 1; i--) { PsiCaseLabelElement labelElement = caseLabelElements[i]; PsiSwitchLabelStatement newLabel = branch.addLabelAfter(labelElement, labelStatement); newLabels.add(newLabel); } for (PsiSwitchLabelStatement newLabel : newLabels) { branch.copyTo(newLabel); } return !newLabels.isEmpty() ? newLabels.get(0) : null; }