Database
db={"fileSystem":[{pp:[{"_id":"a","label":"Root","children":["b",],},{"_id":"b","label":"Nested folder 1","children":["c","d",],"parent":"a"},{"_id":"c","label":"Nested File 1.1","parent":"b"},{"_id":"d","label":"Nested File 1.2","parent":"b"}]}]}
Query
db.fileSystem.aggregate([{"$unwind":"$pp"},{"$replaceRoot":{"newRoot":"$pp"}},{"$match":{"_id":"a"}},{"$graphLookup":{"from":"fileSystem","startWith":"$pp.children","connectFromField":"pp.children","connectToField":"pp._id","as":"nest","depthField":"level",}},])