def METHOD_NAME(d):
    segment = bytes()
    for key, value in d.items():
        if isinstance(value, dict):
            segment += (
                encode_named_type(cls.SECTION_START, key)
                + METHOD_NAME(value)
                + struct.pack("!B", cls.SECTION_END)
            )
        elif isinstance(value, list):
            segment += (
                encode_named_type(cls.LIST_START, key)
                + serialize_list(value)
                + struct.pack("!B", cls.LIST_END)
            )
        else:
            segment += (
                encode_named_type(cls.KEY_VALUE, key)
                + encode_blob(value)
            )
    return segment