<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_dict(self):
 """Convert self to a dict object for serialization."""

        return {
            'level': self.level,
            'id': self.id,
            'text': self.text,
            'inner_html': self.inner_html,
            'children': [child.to_dict() for child in self.children]
        }