def proxied_document_ref(ref_or_document):
    """
    Utility to get reference from document **or** from
    proxied response or return string as is.
    """
    from .document import Document
    if issubclass(type(ref_or_document), Document):
        return ref_or_document.id
    return ref_or_document
