code: protected function groupRootsByScope($roots) {
      $rootsGroupedByScope = array();
  
      foreach($roots as $root) {
        $key = $this->keyForScope($root);
  
        if ( !isset($rootsGroupedByScope[$key]) )
          $rootsGroupedByScope[$key] = array();
  
        $rootsGroupedByScope[$key][] = $root;
      }
  
      return $rootsGroupedByScope;
    }
docs: Given a list of root nodes, it returns an array in which the keys are the
  array of the actual scope column values and the values are the root nodes
  inside that scope themselves
  
  @param   mixed   $roots
  @return  array