def METHOD_NAME(headers):
    """
    Writes a given dictionary to a bytearray object and returns it
    TODO : Point to Protocol doc in the repo
    Args:
        headers: dict of frugal headers to write
    Returns:
        bytearray containing binary headers
    """
    utf8_headers = [(key.encode('utf8'), val.encode('utf8'))
                    for (key, val) in headers.items()]
    size = sum([8 + len(key) + len(val) for (key, val) in utf8_headers])
    buff = bytearray(size + 5)
    pack_into(_UCHAR, buff, 0, _V0)
    pack_into(_UINT, buff, 1, size)
    offset = 5
    for key, value in utf8_headers:
        key_len = len(key)
        pack_into(_UINT, buff, offset, key_len)
        offset += 4
        pack_into('>{0}s'.format(str(key_len)), buff, offset, key)
        offset += key_len
        val_len = len(value)
        pack_into(_UINT, buff, offset, val_len)
        offset += 4
        pack_into('>{0}s'.format(str(val_len)), buff, offset, value)
        offset += val_len
    return buff