def mask2list(bitmask, number=1):
    """
    Convert an integer bitmask into a list of integers.

    >>> mask2list((1 << 14) | (1 << 0))
    [1, 15]
    """
    if not bitmask:
        return []
    this = []
    if bitmask & 1:
        this = [number]
    return this + mask2list(bitmask >> 1, number + 1)