code: function concatenateFactory() {
      var queue = [];
  
      /**
       * Gather a parent if not already gathered.
       *
       * @param {NLCSTChildNode} node - Child.
       * @param {number} index - Position of `node` in
       *   `parent`.
       * @param {NLCSTParentNode} parent - Parent of `child`.
       */
      function concatenate(node, index, parent) {
          if (
              parent &&
              (parent.type === 'ParagraphNode' || parent.type === 'RootNode') &&
              queue.indexOf(parent) === -1
          ) {
              queue.push(parent);
          }
      }
  
      /**
       * Patch one parent.
       *
       * @param {NLCSTParentNode} node - Parent
       * @return {Array.<Array.<string, number>>} - Language
       *  map.
       */
      function one(node) {
          var children = node.children;
          var length = children.length;
          var index = -1;
          var languages;
          var child;
          var dictionary = {};
          var tuple;
  
          while (++index < length) {
              child = children[index];
              languages = child.data && child.data.languages;
  
              if (languages) {
                  tuple = languages[0];
  
                  if (tuple[0] in dictionary) {
                      dictionary[tuple[0]] += tuple[1];
                  } else {
                      dictionary[tuple[0]] = tuple[1];
                  }
              }
          }
  
          return sortDistanceObject(dictionary);
      }
  
      /**
       * Patch all parents in reverse order: this means
       * that first the last and deepest parent is invoked
       * up to the first and highest parent.
       */
      function done() {
          var index = queue.length;
  
          while (index--) {
              patch(queue[index], one(queue[index]));
          }
      }
  
      concatenate.done = done;
  
      return concatenate;
  }
docs: Factory to gather parents and patch them based on their
  childrens directionality.
  
  @return {function(node, index, parent)} - Can be passed
  to `visit`.