import itertools


def pairwise_longest(iterable):
  """Creates a meta-iterator to iterate over current/next values concurrently.

  This is different from itertools pairwise recipe in that it returns the final
  element as (final, None).

  Args:
    iterable: An Iterable of any type.
  Returns:
    An iterable which returns the current and next items in the iterable, or
    None if there is no next. For example, for an iterator over the list
    (1, 2, 3, 4), this would return an iterator as
    ((1, 2), (2, 3), (3, 4), (4, None)).
  """
  # From itertools example documentation.
  a, b = itertools.tee(iterable)
  next(b, None)
  return itertools.zip_longest(a, b)