@Override
  public @NotNull List<@NotNull AnAction> postProcessVisibleChildren(@NotNull AnActionEvent e,
                                                                     @NotNull List<? extends @NotNull AnAction> visibleChildren) {
    LinkedHashSet<AnAction> heaviest = null;
    double maxWeight = DEFAULT_WEIGHT.doubleValue();
    for (AnAction action : visibleChildren) {
      Presentation presentation = e.getUpdateSession().presentation(action);
      if (!presentation.isEnabled() || !presentation.isVisible()) {
        continue;
      }
      double weight = ObjectUtils.notNull(presentation.getClientProperty(WEIGHT_KEY), DEFAULT_WEIGHT).doubleValue();
      if (weight > maxWeight) {
        maxWeight = weight;
        heaviest = new LinkedHashSet<>();
      }
      if (weight == maxWeight && heaviest != null) {
        heaviest.add(action);
      }
    }

    if (heaviest == null) {
      return new ArrayList<>(visibleChildren);
    }

    ArrayList<AnAction> chosen = new ArrayList<>();
    boolean prevSeparator = true;
    for (AnAction action : visibleChildren) {
      final boolean separator = action instanceof Separator;
      if (separator && !prevSeparator) {
        chosen.add(action);
      }
      prevSeparator = separator;

      if (shouldBeChosenAnyway(action)) {
        heaviest.add(action);
      }

      if (heaviest.contains(action)) {
        chosen.add(action);
      }
    }
    ActionGroup other = new ExcludingActionGroup(getDelegate(), heaviest);
    other.getTemplatePresentation().setText(IdeBundle.messagePointer("action.presentation.WeighingActionGroup.text"));
    other.getTemplatePresentation().setPopupGroup(true);
    return JBIterable.from(chosen).append(new Separator()).append(other).toList();
  }
@Override
  public @NotNull List<@NotNull AnAction> postProcessVisibleChildren(@NotNull AnActionEvent e,
                                                                     @NotNull List<? extends @NotNull AnAction> visibleChildren)