Query parent, child, grandchildren to infinity

I’m not sure this is even possible in Wappler, but the concept is an API that queries a table for parent records and all decedents, if I can use that term. It’s a single table of tasks, and a task can have subtasks and a subtask can have sub-subtasks and so one to infinity. There is no limit to the levels of descents, although there could be a practical limit. A task becomes a subtask of a parent by the value of the ParentId field. Parent tasks have a null ParentId.

So a top level record will have a null ParentId and all subtasks have a ParentId of the record that is it’s parent, if that makes sense. It could be from a top level record or any record down the line.

Something like:
-id: 1, parentId: null, name: Parent task 1
—id: 2, parentId: 1, name: Subtask 1 of id 1
-----id: 3, parentId: 2, name: Subtask 1 of id 2
—id: 4, parentId: 1, name: Subtask 2 of id 1
-----id: 5, parentId: 4, name: Subtask 1 of id 4
-----id: 6, parentId: 4, name: Subtask 2 of id 4
—id: 7, parentId: 1, name: Sub task 3 of id 1
-id: 8, parentId: null, name: Parent task 2
—id: 9, parentId: 8, name: Subtask 2 of parent task 2
-----id: 10, parentId: 9, name: Subtask 1 of id 9
etc…

I’ve only shown about 3 levels deep here, but potentially it could go 5 or 10 or 100 levels deep from each parent. And one or more subtasks at each level. I might put some max level at some point, but that’s the concept.

So the easy part is to start by querying the table for all records with a null parentId. That will get me all parent records. Than I need to loop through those records and find all child records, and then for each child record, find all child records of each of those, and so one as deep as it goes.

Is this possible in Wappler and any ideas how to go about it?