'Return the item for the commit matching criteria'

def get_item_by_generation(self, commits, criteria_fn):

    if (not commits):
        return None
    generation = None
    for commit in commits:
        if ((generation is None) or criteria_fn(generation, commit.generation)):
            oid = commit.oid
            generation = commit.generation
    try:
        return self.items[oid]
    except KeyError:
        return None
