def rename_nodes(parse, old2new):
	"""
	replace NODE labels in list structure, old2new is a dict
	"""
	if(type(parse)==list):
		return [ rename_nodes(p, old2new) for p in parse]
	
	if "NODE" in parse and parse["NODE"] in old2new:
		parse["NODE"]=old2new[parse["NODE"]]
	
	if "children" in parse and len(parse["children"])>0:
		parse["children"]=rename_nodes(parse["children"], old2new)
	
	return parse