Try this:
def unpack_into_dict(object):
res = {}
for key, val in object.__dict__.items():
if hasattr(val, '__dict__'):
res[key] = unpack_into_dict(val)
else:
res[key] = val
return res
CLICK HERE to find out more related problems solutions.