for child in self.children:
    return_string.extend(['\n', ' ' * (depth + 1), child.__repr__(depth + 1)])
return ''.join(return_string)
How to pprint a tree data structure that is implemented using classes?