def addBits(byte, numberOfBits, bitmap):
    """Used by ``emptyBlockBitmap`` to turn a byte or part of a byte into a bitstring.

    Turns MSB ``numberOfBits`` into a bitstring and appends it to 
    ``bitmap``.

    NOTE: bits are ordered from LSB to MSB for adding to bitstring. The
    result string has the blocks ordered left to right.

    Args:
        byte (byte array): Byte to turn into a bit string.
        numberOfBits (int): Number of bits (starting from the MSB) to
            convert. This is needed because there is one case where we only
            need to convert the lower half of a byte, instead of an
            entire byte. This is usually called with 4 or 8.
        bitmap (str): Current bitstring. This will be returned with the
            new bits appended.

    Returns:
        str: Bitmap with new bits appended to the end.
    """
    for _ in range(numberOfBits, 0, -1):
        if (byte & 0x01) != 0:
            bitmap = bitmap + '1'
        else:
            bitmap = bitmap + '0'

        byte = byte >> 1

    return bitmap