def chunkify(iterable, n):
    """Break an interable into chunks of size at most 'n'."""
    chunk = None
    for i, x in enumerate(iterable):
        if i % n == 0:
            if chunk is not None:
                yield chunk
            chunk = []
        chunk.append(x)
    yield chunk
