Reformatting a json tree using python