static AnAction @NotNull [] getReordableChildren(@NotNull ActionGroup group,
                                                   AnAction @NotNull [] children,
                                                   @NotNull CustomActionsSchema schema,
                                                   String defaultGroupName,
                                                   String rootGroupName) {
    String text = group.getTemplatePresentation().getText();
    ActionManager actionManager = ActionManager.getInstance();
    ArrayList<AnAction> reorderedChildren = new ArrayList<>();
    ContainerUtil.addAll(reorderedChildren, children);
    for (ActionUrl actionUrl : schema.getActions()) {
      String pg = actionUrl.getParentGroup();
      if (pg == null) continue;
      if (!(pg.equals(text) ||
            pg.equals(defaultGroupName) ||
            pg.equals(actionManager.getId(group)) &&
            actionUrl.getRootGroup().equals(rootGroupName))) {
        continue;
      }
      AnAction ca = actionUrl.getComponentAction();
      if (ca == null) continue;
      int position = actionUrl.getAbsolutePosition();
      if (actionUrl.getActionType() == ActionUrl.ADDED) {
        if (ca == group) {
          LOG.error("Attempt to add group to itself; group ID=" + actionManager.getId(group));
          continue;
        }
        if (position < reorderedChildren.size()) {
          reorderedChildren.add(position, ca);
        }
        else {
          reorderedChildren.add(ca);
        }
      }
      else if (actionUrl.getActionType() == ActionUrl.DELETED) {
        if (!reorderedChildren.remove(ca) && position < reorderedChildren.size()) {
          AnAction ra = reorderedChildren.get(position);
          Presentation rt = ra.getTemplatePresentation();
          Presentation ct = ca.getTemplatePresentation();
          if (rt.getText() == null ? StringUtil.isEmpty(ct.getText()) : rt.getText().equals(ct.getText())) {
            reorderedChildren.remove(position);
          }
        }
      }
    }
    for (int i = 0; i < reorderedChildren.size(); i++) {
      if (reorderedChildren.get(i) instanceof ActionGroup groupToCorrect) {
        AnAction correctedAction = correctActionGroup(groupToCorrect, schema, "", rootGroupName, false);
        reorderedChildren.set(i, correctedAction);
      }
    }

    return reorderedChildren.toArray(AnAction.EMPTY_ARRAY);
  }
static AnAction @NotNull [] getReordableChildren(@NotNull ActionGroup group,
                                                   AnAction @NotNull [] children,
                                                   @NotNull CustomActionsSchema schema,
                                                   String defaultGroupName,
                                                   String rootGroupName)