UITableView with child cells (Tree Structure)

Hi, I'm trying to implement a custom tableview which when tapped on a cell should expand and display its child cells, which further might have their children. Tapping again on the cell should collapse the view.

My data model looks something like below:

var objectTree = [
    MyObject(name: "Parent 1", id: "1", parentId: nil, children: [MyObject(name: "Child 1", id: "2", parentId: "1"), MyObject(name: "Child 2", id: "3", parentId: "1"),]),
    MyObject(name: "Parent 2", id: "4", parentId: nil, children: [MyObject(name: "Child 3", id: "5", parentId: "4", children: [MyObject(name: "Grandchild 1", id: "6", parentId: "5")])])
]

Here, "Parent 1" is the first cell, when tapped on it should expand and display its children "Child 1" & "Child 2" as sub/child cells under the "Parent 1" cell forming a tree-like structure.

Is there a way I can achieve this?

UITableView with child cells (Tree Structure)
 
 
Q