def _bitcmp(bit, bit_ref, wildcard='x'):
    """
    Compares the string representation of a binary number ignoring any bits
    on the reference string 'bit_ref' marked with a wildcard.
    """
    bit = bit.replace('0b', '')
    bit, bit_ref = list(bit), list(bit_ref)
    bit.reverse(); bit_ref.reverse() # Start comparing from LSbit.
    isbiteq = []
    for n in range(len(bit)):
        if bit_ref[n]!=wildcard:
            isbiteq.append(bit[n]==bit_ref[n])

    return all(isbiteq)