def walk_recursive_and_replace(element: TypeBrick): if not element.indexes and "|" in element.kind: element.indexes = [ TypeBrick(kind=index.strip()) for index in element.kind.split("|") ] element.kind = "Union" if element.indexes: for child in element.indexes: walk_recursive_and_replace(child)
def walk_recursive_and_replace(element: TypeBrick): if element.kind == old: element.kind = new if element.indexes: for child in element.indexes: walk_recursive_and_replace(child)