private @NotNull Map<T, List<String>> collectBranchesByRoot(@NotNull BranchStorage storage, @NotNull BranchType branchType) {
    List<DvcsBranchInfo> infos = ContainerUtil.notNullize(storage.getBranches().get(branchType.getName()));

    Map<String, List<String>> infoByPath = new HashMap<>();
    for (DvcsBranchInfo info : infos) {
      List<String> list = infoByPath.computeIfAbsent(info.repoPath, key -> new ArrayList<>());
      list.add(info.sourceName);
    }

    Map<T, List<String>> infoByRepo = new HashMap<>();

    List<T> allRepos = myRepositoryManager.getRepositories();
    List<String> allRepoFavorites = ContainerUtil.notNullize(infoByPath.remove(DvcsBranchUtil.getPathFor(null)));
    if (!allRepoFavorites.isEmpty()) {
      for (T repo : allRepos) {
        List<String> repoList = infoByRepo.computeIfAbsent(repo, key -> new ArrayList<>());
        repoList.addAll(allRepoFavorites);
      }
    }

    infoByPath.forEach((repoPath, list) -> {
      T repo = myRepositoryManager.getRepositoryForRootQuick(VcsUtil.getFilePath(repoPath, true));
      if (repo == null) return;
      List<String> repoList = infoByRepo.computeIfAbsent(repo, key -> new ArrayList<>());
      repoList.addAll(list);
    });

    return infoByRepo;
  }
private @NotNull Map<T, List<String>> collectBranchesByRoot(@NotNull BranchStorage storage, @NotNull BranchType branchType)