def METHOD_NAME(self, element: Any, parent_key: ElementName = None) -> Any:
    """
    Renames an individual element plus its children
    Does not modify in place: creates a new element
    :param element:
    :return:
    """
    typ = type(element)
    if element is None:
        return None
    elif isinstance(element, ElementName):
        # element is a *Reference* to a Class, Slot, or other schema element
        if typ == ElementName:
            # cast generic element names, e.g. for ranges
            if element in self.schema.classes:
                typ = ClassDefinitionName
            elif element in self.schema.enums:
                typ = EnumDefinitionName
            elif element in self.schema.types:
                typ = TypeDefinitionName
        typ_deref = ref_map.get(typ, None)
        if typ_deref in self.rename_function_map:
            return typ(self.rename_function_map[typ_deref](element))
        else:
            return element
    elif isinstance(element, dict):
        # element is a dict; keys may be rewired
        new_element = {}
        for k, v in element.items():
            v2 = self.METHOD_NAME(v, k)
            typ = type(v2)
            new_k = k
            if typ in self.rename_function_map:
                new_k = v2.name
            new_element[new_k] = v2
        return new_element
    elif isinstance(element, list):
        return [self.METHOD_NAME(e) for e in element]
    elif isinstance(element, YAMLRoot):
        # element is a Class, Slot, or other schema element
        new_element = deepcopy(element)
        if typ in self.rename_function_map:
            new_element.name = self.rename_function_map[typ](element.name)
        for k, v in vars(new_element).items():
            setattr(new_element, k, self.METHOD_NAME(v))
        return new_element
    else:
        try:
            element_vars = {k: v for k, v in vars(element).items() if not k.startswith("_")}
            if len(element_vars) == 0:
                return element
            else:
                new_element = deepcopy(element)
                for k, v in vars(new_element).items():
                    setattr(new_element, k, self.METHOD_NAME(v))
                return new_element
        except TypeError:
            return element