def get_min_index(positions, window):
    """
    Given a list of lists representing term positions in a corpus,
    this returns the index of the min term, or nothing if None left.
    """
    for min_index in [window.index(i) for i in sorted(window)]:
        if window[min_index] < positions[min_index][-1]:
            return min_index
    return None