Convert the model into a dict for serialization

    Notify schematics of the sparse fields requested while
    also forcing the resource id & resource type fields to always
    be present no matter the request. Additionally, any includes
    are implicitly added as well & automatically loaded.

    Then normalize the includes, hide private fields, & munge
    the relationships into a format the serializers are
    expecting.

def _to_rest(model, includes=None):
    """ Convert the model into a dict for serialization

    Notify schematics of the sparse fields requested while
    also forcing the resource id & resource type fields to always
    be present no matter the request. Additionally, any includes
    are implicitly added as well & automatically loaded.

    Then normalize the includes, hide private fields, & munge
    the relationships into a format the serializers are
    expecting.
    """

    includes = includes or []
    sparse = goldman.sess.req.fields.get(model.rtype, [])

    if sparse:
        sparse += [model.rid_field, model.rtype_field]
        sparse += includes

    props = model.to_primitive(
        load_rels=includes,
        sparse_fields=sparse,
    )

    props['rid'] = props.pop(model.rid_field)
    props['rtype'] = props.pop(model.rtype_field)

    _to_rest_hide(model, props)
    _to_rest_rels(model, props)

    return props