def links(self, skipself=False): if not skipself: yield self d = self.__dict__ for name in self._children: for link in d[name].links(): yield link