def create_non_dupe(base_name: str, opt_num: int, comparison) -> str:
    """Makes sure base_name is not in comparison, and if it is it's renamed.

    :param base_name: Name to check/make unique.
    :param opt_num: Number of the option base_name belongs to, used in making it unique.
    :param comparison: Dictionary or set to search for base_name in.
    :return: Unique name.
    """
    h = base_name
    if h in comparison:
        n = 0
        h = h + '_O' + str(opt_num)
        h_end = len(h)
        while h in comparison:
            h = h[:h_end] + '_' + str(n)
            n += 1
    return h