def unique(seq, key=None):
	"""
	Create a list or tuple consisting of the unique elements of *seq* and
	preserve their order.

	:param seq: The list or tuple to preserve unique items from.
	:type seq: list, tuple
	:param function key: If key is provided it will be called during the
		comparison process.
	:return: An object of the same type as *seq* and contaning its unique elements.
	"""
	if key is None:
		key = lambda x: x
	preserved_type = type(seq)
	seen = {}
	result = []
	for item in seq:
		marker = key(item)
		if marker in seen:
			continue
		seen[marker] = 1
		result.append(item)
	return preserved_type(result)