Group (@NotNull ActionGroup actionGroup, @NotNull @NlsActions.ActionText String groupName, @NotNull List<? super String> path, @NotNull List<ActionUrl> actionUrls) { path.add(groupName); ActionManager actionManager = ActionManager.getInstance(); String groupId = actionManager.getId(actionGroup); Group group = new Group(groupName, groupId, actionGroup.getTemplatePresentation().getIcon()); List<AnAction> children = new ArrayList<>(Arrays.asList(getActions(actionGroup, actionManager))); for (ActionUrl actionUrl : actionUrls) { Object component = actionUrl.getComponent(); if (component instanceof Group correctedGroup && Objects.equals(correctedGroup.getId(), groupId)) { group.setForceShowAsPopup(correctedGroup.isForceShowAsPopup()); } if (areEqual(path, actionUrl)) { //actual path is shorter when we use custom root AnAction componentAction = actionUrl.getComponentAction(); if (componentAction != null) { if (actionUrl.getActionType() == ActionUrl.ADDED) { if (children.size() > actionUrl.getAbsolutePosition()) { children.add(actionUrl.getAbsolutePosition(), componentAction); } else { children.add(componentAction); } } else if (actionUrl.getActionType() == ActionUrl.DELETED && children.size() > actionUrl.getAbsolutePosition()) { AnAction anAction = children.get(actionUrl.getAbsolutePosition()); if (anAction.getTemplateText() == null ? (componentAction.getTemplateText() != null && !componentAction.getTemplateText().isEmpty()) : !anAction.getTemplateText().equals(componentAction.getTemplateText())) { continue; } children.remove(actionUrl.getAbsolutePosition()); } } } } for (AnAction action : children) { if (action instanceof ActionGroup) { group.addGroup(createCorrectedGroup((ActionGroup)action, getName(action), path, actionUrls)); } else if (action instanceof Separator) { group.addSeparator(); } else { String id = actionManager.getId(action); if (id != null) { group.addActionId(id); } } } path.remove(path.size() - 1); return group; }