def METHOD_NAME(path):
	nodes = ('\\', '/')
	if os_win32:
		nodes = ('/', '\\')
	path = path.replace(nodes[0], nodes[1]).rstrip(nodes[1])
	if os_win32:
		# replace single backslashes with double
		path = path.replace('\\', '\\\\')
		# remove extra backslashes
		while '\\\\\\' in path:
			path = path.replace('\\\\\\', '\\\\')
	else:
		# remove extra forward slashes
		while '//' in path:
			path = path.replace('//', '/')
	return path