code: def group_children( index, shared, min_kids=10, stop_types=STOP_TYPES, delete_children=True ):
      
      to_compress = []
      
      for to_simplify in list(iterindex( index )):
          if not isinstance( to_simplify, dict ):
              continue
          for typ,kids in children_types( to_simplify, index, stop_types=stop_types ).items():
              kids = [k for k in kids if k and simple(k,shared, to_simplify)]
              if len(kids) >= min_kids:
                  # we can group and compress out...
                  to_compress.append( (to_simplify,typ,kids))
      
      for to_simplify,typ,kids in to_compress:
          typ_address = new_address(index)
          kid_addresses = [k['address'] for k in kids]
          index[typ_address] = {
              'address': typ_address,
              'type': MANY_TYPE,
              'name': typ,
              'size': sum( [k.get('size',0) for k in kids], 0),
              'parents': [to_simplify['address']],
          }
          
          shared[typ_address] = index[typ_address]['parents']
          to_simplify['refs'][:] = [typ_address]
          
          if delete_children:
              for address in kid_addresses:
                  try:
                      del index[address]
                  except KeyError, err: 
                      pass # already compressed out
                  try:
                      del shared[address]
                  except KeyError, err:
                      pass # already compressed out
              index[typ_address]['refs'] = []
          else:
              index[typ_address]['refs'] = kid_addresses
docs: Collect like-type children into sub-groups of objects for objects with long children-lists
      
      Only group if:
      
          * there are more than X children of type Y
          * children are "simple"
              * individual children have no children themselves
              * individual children have no other parents...