def METHOD_NAME(obj: Model, replace: Document | None = None) -> None:
    """
    Removes the document from any previously displayed bokeh object
    """
    for model in obj.select({'type': Model}):
        prev_doc = model.document
        model._document = None
        if prev_doc:
            prev_doc.METHOD_NAME(model)
        if replace:
            model._document = replace