- def children(self, db_conn: DatabaseConnection) -> list[Process]:
- """Return child Processes as determined by self.child_ids."""
- return [self.__class__.by_id(db_conn, id_) for id_ in self.child_ids]
+ def get_descendants(self, db_conn: DatabaseConnection) ->\
+ dict[int, dict[str, object]]:
+ """Return tree of descendant Processes"""
+ descendants = {}
+ for id_ in self.child_ids:
+ child = self.__class__.by_id(db_conn, id_)
+ descendants[id_] = {'process': child,
+ 'children': child.get_descendants(db_conn)}
+ return descendants