def flatten_object(obj, path, ret):
	"""Takes an object obj and flattens it into a dictionary ret.

	For instance { "x": { "y": 123 } } is turned into { "x__y": 123 }.
	"""
	for k, v in obj.items():
		if isinstance(v, dict):
			flatten_object(v, (path + "__" if path else "") + k + "__", ret)
		elif isinstance(v, list):
			# don't peek inside lists
			pass
		else:
			ret[path + k] = v
	return ret