code: def prev_this_next(it, sentinel=None):
      
      i1, i2, i3 = tee(it, 3)
      next(i3, None)
      return zip(chain([sentinel], i1), i2, chain(i3, [sentinel]))
docs: Utility to return (prev, this, next) tuples from an iterator