import copy


def dict_path(from_d,to_d={},l=[]):
	"""
	Returns a dictionary with the path in which each of the keys is found

	Parameters:
		from_d : dict
			Dictionary that contains all the keys, values
		to_d : dict
			Dictionary to which the results will be appended

	Example: 
		dict_path({'level1':{'level2':{'level3':'value'}}})
		Returns
			{'level1': [],
		 	 'level2': ['level1'],
		 	 'level3': ['level1', 'level2']
		 	}
	"""
	for k,v in list(from_d.items()):
		if isinstance(v,dict):
			to_d[k]=l
			_l=copy.deepcopy(l)
			_l.append(k)
			to_d=dict_path(from_d[k],to_d,_l)
		else:
			to_d[k]=l
	_to_d=to_d.copy()
	to_d={}
	return _to_d