private static void doBuildProjectTree(MavenProjectsManager manager, Map<MavenProject, Integer> res, List<MavenProject> rootProjects, int depth) {
    MavenProject[] rootProjectArray = rootProjects.toArray(new MavenProject[0]);
    Arrays.sort(rootProjectArray, new MavenProjectComparator());

    for (MavenProject project : rootProjectArray) {
      if (!res.containsKey(project)) {
        res.put(project, depth);

        doBuildProjectTree(manager, res, manager.getModules(project), depth + 1);
      }
    }
  }
private static void doBuildProjectTree(MavenProjectsManager manager, Map<MavenProject, Integer> res, List<MavenProject> rootProjects, int depth)