Probably `itertools.takewhile` http://docs.python.org/2/library/itertools.html#itertools.takewhile (which i had to look up, I don't know the entire module off-by-heart)