private AnAction @NotNull [] merge(AnAction @NotNull [] head, AnAction @NotNull [] tail) {
      var result = new ArrayList<AnAction>(head.length + tail.length);
      result.addAll(Arrays.asList(head));
      myMoreActionGroup.removeAll();
      if (ArrayUtil.getLastElement(head) instanceof MoreActionGroup) {
        result.remove(result.size() - 1);
      }
      result.add(Separator.create());
      result.addAll(Arrays.asList(tail));
      if (ArrayUtil.getLastElement(tail) instanceof MoreActionGroup) {
        myMoreActionGroup.addAll((ActionGroup) ArrayUtil.getLastElement(tail));
        result.remove(result.size() - 1);
      }
      if (ArrayUtil.getLastElement(head) instanceof MoreActionGroup) {
        myMoreActionGroup.add(Separator.create());
        myMoreActionGroup.addAll((ActionGroup) ArrayUtil.getLastElement(head));
      }
      result.add(myMoreActionGroup);
      return result.toArray(EMPTY_ARRAY);
    }
private AnAction @NotNull [] merge(AnAction @NotNull [] head, AnAction @NotNull [] tail)