def METHOD_NAME(self, key, constructor=None):
    if key in self.children:
        child = self.children[key]
    elif constructor is not None:
        child = self.children[key] = constructor()
    else:
        raise KeyError(f"Cannot get key {key}")
    return child