class NextValueWrapper(object):

    def __init__(self, iterator):
        self.iterator = iterator
self.next_value = None
self.finished = False
self.get()

def get(self):
    if self.finished:
        return
value = self.next_value
try:
    self.next_value = next(self.iterator)
except StopIteration:
    self.finished = True
return value
Merge two sorted iterators without replace