@Override
  public AnAction @NotNull [] getChildren(@NotNull AnActionEvent e,
                                          @NotNull Project project,
                                          @NotNull GitRepository root,
                                          @NotNull CommitId commit) {
    VcsLogUi logUI = e.getData(VcsLogDataKeys.VCS_LOG_UI);
    List<VcsRef> refs = e.getData(VcsLogDataKeys.VCS_LOG_REFS);
    if (logUI == null || refs == null) {
      return EMPTY_ARRAY;
    }

    List<VcsRef> branchRefs = ContainerUtil.filter(refs, ref -> {
      if (ref.getType() == GitRefManager.LOCAL_BRANCH) {
        return !ref.getName().equals(root.getCurrentBranchName());
      }
      if (ref.getType() == GitRefManager.REMOTE_BRANCH) return true;
      return false;
    });
    List<VcsRef> tagRefs = ContainerUtil.filter(refs, ref -> ref.getType() == GitRefManager.TAG);

    VcsLogProvider provider = logUI.getDataPack().getLogProviders().get(root.getRoot());
    if (provider != null) {
      VcsLogRefManager refManager = provider.getReferenceManager();
      Comparator<VcsRef> comparator = refManager.getLabelsOrderComparator();
      branchRefs = ContainerUtil.sorted(branchRefs, comparator);
      tagRefs = ContainerUtil.sorted(tagRefs, comparator);
    }


    List<AnAction> groups = new ArrayList<>();

    if (!branchRefs.isEmpty()) {
      GitVcsSettings settings = GitVcsSettings.getInstance(project);
      boolean showBranchesPopup = branchRefs.size() > MAX_BRANCH_GROUPS;

      GitRepositoryManager repositoryManager = GitRepositoryManager.getInstance(project);
      List<GitRepository> allRepositories = repositoryManager.getRepositories();

      Set<GitBranch> commonBranches = new HashSet<>();
      commonBranches.addAll(GitBranchUtil.getCommonLocalBranches(allRepositories));
      commonBranches.addAll(GitBranchUtil.getCommonRemoteBranches(allRepositories));

      List<AnAction> branchActionGroups = new ArrayList<>();
      for (VcsRef ref : branchRefs) {
        AnAction group = createBranchGroup(project, ref, root, allRepositories, commonBranches, settings, showBranchesPopup);
        ContainerUtil.addIfNotNull(branchActionGroups, group);
      }

      DefaultActionGroup branchesGroup = new DefaultActionGroup(GitBundle.message("branches.branches"), branchActionGroups);
      branchesGroup.setPopup(showBranchesPopup);
      groups.add(branchesGroup);
    }

    if (!tagRefs.isEmpty()) {
      boolean showTagsPopup = tagRefs.size() > MAX_TAG_GROUPS;

      List<AnAction> tagActionGroups = new ArrayList<>();
      for (VcsRef ref : tagRefs) {
        tagActionGroups.add(createTagGroup(project, ref, root, showTagsPopup));
      }

      DefaultActionGroup tagsGroup = new DefaultActionGroup(GitBundle.message("branches.tags"), tagActionGroups);
      tagsGroup.setPopup(showTagsPopup);
      groups.add(tagsGroup);
    }

    return groups.toArray(EMPTY_ARRAY);
  }
@Override
  public AnAction @NotNull [] getChildren(@NotNull AnActionEvent e,
                                          @NotNull Project project,
                                          @NotNull GitRepository root,
                                          @NotNull CommitId commit)