docs: def to_dict(self, depth=-1, ordered=True, **kwargs):
          """Returns a dict representation of the object."""
          if ordered:
              dict_fun = OrderedDict
          else:
              dict_fun = dict
          out = dict_fun()
          out['name'] = self._name
          out['id'] = self._id
          if depth != 0:
              out['children'] = dict_fun([(name, child.to_dict(depth=depth-1))
                                          for name, child in self._children.items()])  # noqa
          return out