code: def _collect_box_count(self, boxes):
          
          count = Counter([box.box_id for box in boxes])
  
          # Add the counts in the superboxes.
          for box in boxes:
              if hasattr(box, 'box'):
                  count.update(self._collect_box_count(box.box))
  
          return count
docs: Count the occurences of each box type.