def btc_witness_script_serialize(_stack):
    """
    Given a deserialized witness script stack (i.e. the input-specific witness, as an array of
    Nones, ints, and strings), turn it back into a hex-encoded script
    """
    stack = _stack
    if encoding.json_is_base(_stack, 16):
        # hex-to-bin all hex strings 
        stack = encoding.json_changebase(_stack, lambda x: binascii.unhexlify(x))

    return encoding.safe_hexlify(_btc_witness_serialize_unit(len(stack)) + ''.join(map(lambda stack_unit: _btc_witness_serialize_unit(stack_unit), stack)))
Given a deserialized witness script stack (i.e. the input-specific witness, as an array of
    Nones, ints, and strings), turn it back into a hex-encoded script