Use itertools module to select commits