def METHOD_NAME(lin, rank):
    "Remove lineage tuples from given lineage `lin` until `rank` is reached."
    lin = list(lin)
    txl = taxlist()
    before_rank = []
    for txl_rank in txl:
        if txl_rank != rank:
            before_rank.append(txl_rank)
        else:
            break
    # are we already above rank?
    if lin and lin[-1].rank in before_rank:
        return tuple(lin)
    while lin and lin[-1].rank != rank:
        lin.pop()
    return tuple(lin)