code: def facetrecordtrees(table, key, start='start', stop='stop'):
      
  
      import intervaltree
      getstart = attrgetter(start)
      getstop = attrgetter(stop)
      getkey = attrgetter(key)
      trees = dict()
      for rec in records(table):
          k = getkey(rec)
          if k not in trees:
              trees[k] = intervaltree.IntervalTree()
          trees[k].addi(getstart(rec), getstop(rec), rec)
      return trees
docs: Construct faceted interval trees for the given table, where each node in 
      the tree is a record.