code: function nestTwoLevels(samples) {
    return samples.reduce(function(acc, sample) {
      var page     = sample.hierarchy.length > 0 ? sample.hierarchy[0] : 'API';
      var heading  = sample.hierarchy.length > 1 ? sample.hierarchy[1] : 'Samples';
      acc[page] = acc[page] || {};
      acc[page][heading] = acc[page][heading] || [];
      acc[page][heading].push(sample);
      return acc;
    }, {});
  }
docs: /*
  {
  pageName: {
  heading: [ sample, sample ],
  heading: [ sample, sample ]
  },
  page: {
  heading: [ sample, sample ]
  }
  }