def METHOD_NAME(obj):
    offset = obj.get("__Serialized__", 0)
    if offset > 0:
        sub_header = msgpack.loads(
            frames[offset],
            object_hook=msgpack_decode_default,
            use_list=False,
            **msgpack_opts,
        )
        offset += 1
        sub_frames = frames[offset : offset + sub_header["num-sub-frames"]]
        if deserialize:
            if "compression" in sub_header:
                sub_frames = decompress(sub_header, sub_frames)
            return merge_and_deserialize(
                sub_header, sub_frames, deserializers=deserializers
            )
        else:
            return Serialized(sub_header, sub_frames)
    offset = obj.get("__Pickled__", 0)
    if offset > 0:
        sub_header = msgpack.loads(frames[offset])
        offset += 1
        sub_frames = frames[offset : offset + sub_header["num-sub-frames"]]
        if allow_pickle:
            return pickle.loads(sub_header["pickled-obj"], buffers=sub_frames)
        else:
            raise ValueError(
                "Unpickle on the Scheduler isn't allowed, set `distributed.scheduler.pickle=true`"
            )
    return msgpack_decode_default(obj)