Database

db={"walls":[{"_id":ObjectId("5e95b4b49d3e303d667a8b71"),"groupId":ObjectId("5e8c5caa75b1cd342a1175eb"),"comments":[{"_id":ObjectId("5e95b4b49d3e303d667a8b72"),"commentId":ObjectId("5e95b4b49d3e303d667a8b70")},{"_id":ObjectId("5e95b4ef80ae1244693aa857"),"commentId":ObjectId("5e95b4ef80ae1244693aa856")},{"_id":ObjectId("5e95b51080ae1244693aa859"),"commentId":ObjectId("5e95b51080ae1244693aa858")},{"_id":ObjectId("5e95b51d80ae1244693aa85b"),"commentId":ObjectId("5e95b51d80ae1244693aa85a")},{"_id":ObjectId("5e95b53580ae1244693aa85e"),"commentId":ObjectId("5e95b53580ae1244693aa85c")}],}],"comments":[{"_id":ObjectId("5e95b4b49d3e303d667a8b70"),"parentCommentId":null,"text":"Hello parent 1"},{"_id":ObjectId("5e95b4ef80ae1244693aa856"),"parentCommentId":null,"text":"Hello parent 2","date":ISODate("2020-04-14T13:04:47.860Z")},{"_id":ObjectId("5e95b51080ae1244693aa858"),"parentCommentId":ObjectId("5e95b4b49d3e303d667a8b70"),"text":"Hello child 1 parent 1"},{"_id":ObjectId("5e95b51d80ae1244693aa85a"),"parentCommentId":ObjectId("5e95b4b49d3e303d667a8b70"),"text":"Hello child 2 parent 1"},{"_id":"5e95b53580ae1244693aa85c","parentCommentId":ObjectId("5e95b4ef80ae1244693aa856"),"text":"Hello child 1 parent 2",}]}

Query

db.walls.aggregate([{$lookup:{from:"comments",let:{commentIds:"$comments.commentId"},pipeline:[{$match:{$expr:{$in:["$_id","$$commentIds"]}}},{$graphLookup:{from:"comments",startWith:"$_id",connectFromField:"parentCommentId",connectToField:"parentCommentId",as:"childs"}}],as:"comments"}}])

Result