def _get_out_object(ctx):
    """Returns out object from context

    :param om: out_message
    :return: out_object
    """
    om = ctx.descriptor.out_message
    oo = None
    if ctx.descriptor.is_out_bare():
        oo = next(iter(ctx.out_object))
    elif len(om._type_info) == 0:
        oo, = ctx.out_object
    elif len(om._type_info) == 1:
        om, = om._type_info.values()
        oo, = ctx.out_object
    else:
        oo = om.get_serialization_instance(ctx.out_object)
    return oo
