import re


def handle_duplicate_name(contig_name, names_seen):
    """Add a tiebreaker to a duplicate contig name."""
    name = re.sub(r'_v\d+$', '', contig_name, re.IGNORECASE)

    names_seen[name] += 1

    if names_seen[name] > 1:
        name += '_v{}'.format(names_seen[name])

    return name