def _sum_counters(*counters_list):
 result = {}
 for counters in counters_list:
  for (group, counter_to_amount) in counters.items():
   for (counter, amount) in counter_to_amount.items():
    result.setdefault(group, {})
    result[group].setdefault(counter, 0)
    result[group][counter] += amount
 return result

def _sum_counters ( * counters_list ) : result = { } for counters in counters_list : for ( group , counter_to_amount ) in counters . items ( ) : for ( counter , amount ) in counter_to_amount . items ( ) : result . setdefault ( group , { } ) result [ group ] . setdefault ( counter , 0 ) result [ group ] [ counter ] += amount return result
combine many maps from group to counter to amount .