def _int_to_binary(integer, size=None):
    """Return bit list representation of integer.

    If size is given, binary string is padded with 0s, or clipped to the size.
    """
    binary_list = map(int, format(integer, 'b'))

    if size is None:
        return binary_list
    else:
        if len(binary_list) > size:
            # Too long, take only last n
            return binary_list[len(binary_list)-size:]
        elif size > len(binary_list):
            # Too short, pad
            return [0]*(size-len(binary_list)) + binary_list
        else:
            # Just right
            return binary_list
Return bit list representation of integer.

    If size is given, binary string is padded with 0s, or clipped to the size.