def dump_plotting_tree(d):
if isinstance(d, dict):
expanded = dict()
for k, v in d.items():
if k.startswith("_"): # do we want this?
continue
try:
json.dumps(v)
expanded[k] = v
except TypeError:
try:
expanded[k] = dump_plotting_tree(v.__dict__)
except AttributeError:
expanded[k] = repr(v)
return expanded
else:
if isinstance(d, str):
return d
return repr(d)