Database
[{"id":"A","parentId":null},{"id":"B","parentId":"A"}]
Query
db.collection.aggregate([{$limit:1},{"$graphLookup":{"from":"collection","startWith":null,"connectFromField":"id","connectToField":"parentId","as":"children","depthField":"depth"}},{"$unwind":"$children"},{"$replaceRoot":{"newRoot":{id:"$children.id",depth:"$children.depth"}}}])