def merge_lists(src, dest, insert=True):
    """Merge lists avoiding duplicates"""
    if insert:
        for x in reversed(src):
            if x in dest:
                continue
            dest.insert(0, x)
    else:
        dest.extend([x for x in src if x not in dest])
    return dest