code: def layer_groups(ordering, length=2):
     
     group_orderings = defaultdict(list)
     for el in ordering:
        group_orderings[el[:length]].append(el)
     return group_orderings
docs: Splits a global ordering of Layers into groups based on a slice of
     the spec.  The grouping behavior can be modified by changing the
     length of spec the entries are grouped by.