Use itertools.ifilter() for better readability