'Dump counters as a dict'

def to_dict(self, get_value=None):

    self.trim()
    result = {}
    for (key, value) in iteritems(self.counters):
        if (get_value is not None):
            value = getattr(value, get_value)
        r = result
        for _key in key[:(-1)]:
            r = r.setdefault(_key, {})
        r[key[(-1)]] = value
    return result
