def cu_mask_to_int(cu_mask):
    """ A utility function that takes an array of booleans and returns an
    integer with 1s wherever there was a "True" in the array. The value at
    index 0 is the least significant bit. """
    n = 0
    for b in reversed(cu_mask):
        n = n << 1
        if b:
            n |= 1
    return n