title: How to Map Reduce nested arrays with Underscore.js
body: <p>Given: </p>
  
  <pre><code>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
          }, ...
  </code></pre>
  
  <p>What I want is to filter by <code>group_type.id == "RECIEN_NACIDO"</code> and <code>doses[]._id == "BCG_UNICA"</code> then get a total sumatory of <code>frequencies[].number_applied</code></p>
  
  <p>I tried: </p>
  
  <pre><code>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;
            }
          });
        }
      });
    });
  });
  </code></pre>
  
  <p>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!</p>