title: How not to miss the next element after itertools.takewhile()
body: <p>Say we wish to process an iterator and want to handle it by chunks.<br>
  The logic per chunk depends on previously-calculated chunks, so <code>groupby()</code> does not help.  </p>
  
  <p>Our friend in this case is itertools.takewhile():  </p>
  
  <pre><code>while True:
      chunk = itertools.takewhile(getNewChunkLogic(), myIterator)
      process(chunk)
  </code></pre>
  
  <p>The problem is that <code>takewhile()</code> needs to go past the last element that meets the new chunk logic, thus 'eating' the first element for the next chunk.  </p>
  
  <p>There are various solutions to that, including wrapping or à la C's <code>ungetc()</code>, etc..<br>
  My question is: is there an <strong>elegant</strong> solution?</p>