def spawn_or_create_counter(parent: Optional[Counter]): if parent is not None: return parent.spawn_child() else: return Counter()