ensure Python 2 compatibility with filter() using itertools.ifilter