Given a file that is known to be a symlink, trace it to its ultimate
	target.

	Raises TargetNotPresent when the target cannot be determined.
	Raises ValueError when the specified link is not a symlink.

def trace_symlink_target(link):
	"""
	Given a file that is known to be a symlink, trace it to its ultimate
	target.

	Raises TargetNotPresent when the target cannot be determined.
	Raises ValueError when the specified link is not a symlink.
	"""

	if not is_symlink(link):
		raise ValueError("link must point to a symlink on the system")
	while is_symlink(link):
		orig = os.path.dirname(link)
		link = readlink(link)
		link = resolve_path(link, orig)
	return link