How to Map Reduce nested arrays with Underscore.js

Given:

appliedDoses = {
  "_id": "MAIN",
  "scheme": {
    "_id": "MAIN_SCHEME",
    "name": "ESQUEMA CLASICO",
    "vaccines": [
      {
      "_id": "BCG",
      "__v": 0,
      "doses": [
        {
        "_id": "BCG_UNICA",
        "frequencies": [
          {
          "_id": "BCG_UNICA_RECIEN_NACIDO",
          "group_type": {
            "_id": "RECIEN_NACIDO",
            "name": "RECIEN NACIDO"
          },
          "__v": 0,
          "status": true,
          "number_applied": 10
        }, ...

What I want is to filter by group_type.id == "RECIEN_NACIDO" and doses[]._id == "BCG_UNICA" then get a total sumatory of frequencies[].number_applied

I tried:

async.each(appliedDose, function(scheme){
  async.each(scheme.scheme.vaccines, function(vaccine){
    async.each(vaccine.doses, function(dose){ 
      if(dose._id == getDose) {
        async.each(dose.frequencies, function(frequencie){
          if(frequencie.group_type._id == getGroup) {
            applied += frequencie.number_applied;
          }
        });
      }
    });
  });
});

But my code isn't quite efficiently and I was wondering if MapReduce can be used to improve it. Can somebody give me a hint? Help is much appreciated!

I'm a little confused by the object you're dealing with so I'll try to deal in abstraction. What you're probably looking to do here is easier and faster if you break it down.

get the collection that results from filtering by: group_type._id == "RECIEN_NACIDO" && doses._id

get the array of number_applied's by plucking them out with _.pluck

reduce that with sum: _.reduce(numAppliedArray, function(sum, x) { return sum + x}, 0);