def prev_fn(rank_fn_dict, rank):
    """Get the filepath for the previous interval in rank. The first interval links to the last"""
    prev_rank = len(rank_fn_dict) if rank == 1 else rank - 1
    return rank_fn_dict[prev_rank]
