puoi utilizzare l'aggregazione mongodb per ottenere l'output esatto come richiesto da
Account..aggregate([
{$match:{'buildings.gateways.devices.verificationCode':"4146"}},
{$unwind:"$buildings"},
{$unwind:"$buildings.gateways"},
{$unwind:"$buildings.gateways.devices"},
{$match:{'buildings.gateways.devices.verificationCode':"4146"}}
])