import itertools


def baked_chunks(original_chunks, badge_chunk):
    """
    Returns an iterable of chunks that places the Open Badges baked chunk
    and filters out any previous Open Badges chunk that may have existed.
    """
    def is_not_previous_assertion(chunk):
        if chunk[1].startswith(b'openbadges\x00'):
            return False
        return True

    first_slice = next(original_chunks)
    last_slice = list(filter(
        is_not_previous_assertion,
        original_chunks
    ))

    return itertools.chain([first_slice], [badge_chunk], last_slice)