def METHOD_NAME(collection, meta):
    """Determine the parent document for the document that is to be
    ingested."""
    parent = ensure_dict(meta.get("parent"))
    parent_id = meta.get("parent_id", parent.get("id"))
    if parent_id is None:
        return
    parent = Document.by_id(parent_id, collection=collection)
    if parent is None:
        raise BadRequest(
            response=jsonify(
                {"status": "error", "message": "Cannot load parent document"},
                status=400,
            )
        )
    return parent