Deduplicates assigned paths by incrementing numbering

def _deduplicate_items(cls, items):
        "Deduplicates assigned paths by incrementing numbering"
        counter = Counter([path[:i] for path, _ in items for i in range(1, len(path)+1)])
        if sum(counter.values()) == len(counter):
            return items

        new_items = []
        counts = defaultdict(lambda: 0)
        for i, (path, item) in enumerate(items):
            if counter[path] > 1:
                path = path + (util.int_to_roman(counts[path]+1),)
            elif counts[path]:
                path = path[:-1] + (util.int_to_roman(counts[path]+1),)
            new_items.append((path, item))
            counts[path] += 1
        return new_items