def _next_pair_or_none(iterator):
    """
    Returns the next pair in an iterator of pairs, or a pair of None.
    """
    try:
        return next(iterator)
    except StopIteration:
        return None, None
