def rmtree(filepath, ignore_errors=False, onerror=None):
	"""
	Re-implementation of shutil.rmtree that checks for reparse points
	(junctions/symbolic links) before iterating folders.
	"""
	
	def rm(fn, childpath):
		try:
			fn(childpath)
		except:
			if not ignore_errors:
				if onerror is None:
					raise
				else:
					onerror(fn, childpath, sys.exc_info()[0])
	
	def visit_files(root, targets):
		for target in targets:
			rm(os.unlink, os.path.join(root, target))
	
	def visit_dirs(root, targets):
		for target in targets:
			childpath = os.path.join(root, target)
			rmtree(childpath, ignore_errors, onerror)
	
	if is_reparse_point(filepath):
		rm(delete_reparse_point, filepath)
		return
	
	for root, dirs, files in os.walk(filepath):
		visit_files(root, files)
		visit_dirs(root, dirs)
	
	rm(os.rmdir, filepath)

	Re-implementation of shutil.rmtree that checks for reparse points
	(junctions/symbolic links) before iterating folders.
	
recipes/Python/578849_Reimplementatirmtree_supporting_Windows_reparse_/recipe-578849.py