@staticmethod
def get_stale_builds(build_timestamps, num_builds_to_retain=2):
    """
        Given a list of (build, timestamp) tuples, determine which are stale.

        :param num_builds_to_retain: number of builds to keep at a minimum.

        """
    sorted_items = sorted(build_timestamps, key=lambda bt: bt[1])
    total_builds = len(sorted_items)
    yielded_builds = 0
    for item in sorted_items:
        if total_builds - yielded_builds <= num_builds_to_retain:
            break
        build, timestamp = item
        yield build
        yielded_builds += 1
