Database
[{name:"XYZ",location:["A","B","C","D"]},{name:"XYZ",location:["M","N"]},{name:"ABC",location:["P","Q","R","S"]}]
Query
db.collection.aggregate([{"$match":{name:"XYZ"}},{"$unwind":"$location"},{"$group":{"_id":"$name","location":{"$push":"$location"}}},{"$project":{name:"$_id",location:1,_id:0}}])