Given a hex-encoded serialized witness script, turn it into a witness stack
    (i.e. an array of Nones, ints, and strings)

def btc_witness_script_deserialize(_script):
    """
    Given a hex-encoded serialized witness script, turn it into a witness stack
    (i.e. an array of Nones, ints, and strings)
    """

    script = None
    if isinstance(_script, str) and re.match('^[0-9a-fA-F]*$', _script):
        # convert from hex to bin, safely
        script = binascii.unhexlify(_script)
    else:
        script = _script[:]

    # pointer to byte offset in _script (as an array due to Python scoping rules)
    ptr = [0]

    witness_stack_len = read_var_int(ptr, script)
    witness_stack = []

    for _ in xrange(0, witness_stack_len):

        stack_item = read_var_string(ptr, script)
        witness_stack.append(stack_item)

    return witness_stack