def serialize(root):
	"""
	Serialize a binary tree in depth first, left first order. We assume node values
	do not contain the comma character.
	"""

	def dfs_preorder(root):
		nodes_to_visit = [root]
		while len(nodes_to_visit) > 0:
			node = nodes_to_visit.pop(0)
			if node is not None:
				nodes_to_visit.insert(0, node.left)
				nodes_to_visit.insert(1, node.right)
			yield node

	return ','.join((
		node.val if node is not None else 'None'
		for node in dfs_preorder(root)
	))