void (@NotNull PsiStatement anchor, @NotNull PsiCodeBlock parentBlock) { PsiStatement[] siblingStatements = parentBlock.getStatements(); List<PsiStatement> statements = Arrays.asList(siblingStatements); int ifIndex = statements.indexOf(anchor); if (ifIndex >= 0 && ifIndex < siblingStatements.length - 1) { int labelIndex = ContainerUtil.indexOf(statements.subList(ifIndex, statements.size()), st -> st instanceof PsiSwitchLabelStatement); int limit = labelIndex != -1 ? labelIndex + ifIndex : siblingStatements.length; int startOffset = ifIndex + 1; int endOffset = limit - 1; if (startOffset <= endOffset) { parentBlock.deleteChildRange(siblingStatements[startOffset], siblingStatements[endOffset]); } } }