def unique(seq, idfunc=None):
    """
	Unique a list or tuple and preserve the order

	@type idfunc: Function or None
	@param idfunc: If idfunc is provided it will be called during the
	comparison process.
	"""
    if idfunc is None:
        idfunc = lambda x: x
    preserved_type = type(seq)
    seen = {}
    result = []
    for item in seq:
        marker = idfunc(item)
        if marker in seen:
            continue
        seen[marker] = 1
        result.append(item)
    return preserved_type(result)
