private static @NotNull List<PsiExpression> getElementsToReplace(@NotNull List<@NotNull PsiSwitchLabelStatementBase> labels) {
    List<PsiExpression> elementsToReplace = new ArrayList<>();
    for (PsiSwitchLabelStatementBase label : labels) {
      if (label instanceof PsiSwitchLabeledRuleStatement rule) {
        PsiStatement body = rule.getBody();
        if (body instanceof PsiExpressionStatement statement) {
          ContainerUtil.addIfNotNull(elementsToReplace, statement.getExpression());
        }
      }
      else {
        PsiElement next = PsiTreeUtil.skipWhitespacesAndCommentsForward(label);
        if (next instanceof PsiYieldStatement yieldStatement) {
          ContainerUtil.addIfNotNull(elementsToReplace, yieldStatement.getExpression());
        }
      }
    }
    return elementsToReplace;
  }
private static @NotNull List<PsiExpression> getElementsToReplace(@NotNull List<@NotNull PsiSwitchLabelStatementBase> labels)