import itertools


def sync_iters(chunker, sources):
    """Return dict of iterators over sources (dict name -> iter),
    synchronized using chunker.

    If only one array iter is provided, assume no syncing is needed
    """
    names = list(sources.keys())
    sources = list(sources.values())
    if len(sources) == 1:
        return {names[0]: sources[0]}

    teed = itertools.tee(chunker(*sources),
                         len(sources))

    def get_item(iterable, index):
        for x in iterable:
            yield x[index]

    return {names[i]: get_item(teed[i], i)
            for i in range(len(names))}