def uniq(seq, idfun=lambda x: x):
    """
    Order-preserving unique function.
    """
    seen = {}
    result = []
    for item in seq:
        marker = idfun(item)
        if marker in seen:
            continue
        seen[marker] = 1
        result.append(item)
    return result
