code: def get_tree_roots(paths):
      """Return common root paths for a set of paths
  
      This function determines the smallest set of common root
      paths and sorts all given paths under the respective
      root.
  
      Returns
      -------
      dict
        paths by root
      """
      paths_ws = [_with_sep(p) for p in paths]
      # sort all paths under their potential roots
      roots = {}
      # start from the top to get all paths down the line
      # and collate them into as few roots as possible
      for s in sorted(paths_ws):
          if any([s.startswith(r) for r in roots]):
              # this path is already covered by a known root
              continue
          # find all sub paths
          subs = [p for p in paths if p.startswith(s)]
          roots[s.rstrip(sep)] = subs
      return roots
  
imports: import logging
  import sys
  from time import time
  from os import listdir
  from os.path import join
  from os.path import isdir
  from os.path import relpath
  from os.path import sep
  import json
  from typing import TypeVar
  from datalad.utils import with_pathsep
  from datalad.utils import path_startswith, path_is_subpath, ensure_unicode, getargspec
  from datalad.support.gitrepo import GitRepo
  from datalad.support.exceptions import CapturedException
  from datalad import cfg
  from datalad.dochelpers import single_or_plural
  from datalad.ui import ui
  import datalad.support.ansi_colors
label_desc: Use image node_id 2 for calling a global function with example usage: get_tree_roots(paths) and returns: roots