def getAggregator(cls, instanceId, name):
    """Gets the aggregate stat for the given stat."""
    parent = cls.parentMap.get(instanceId)
    while parent:
      stat = cls.getStat(parent, name)
      if stat:
        return stat, parent
      parent = cls.parentMap.get(statsId(parent))
Gets the aggregate stat for the given stat.