docs: function mergeChildren(children) {
              var nameToItems = ts.createMap();
              ts.filterMutate(children, function (child) {
                  var decl = child.node;
                  var name = decl.name && nodeText(decl.name);
                  if (!name) {
                      // Anonymous items are never merged.
                      return true;
                  }
                  var itemsWithSameName = nameToItems[name];
                  if (!itemsWithSameName) {
                      nameToItems[name] = child;
                      return true;
                  }
                  if (itemsWithSameName instanceof Array) {
                      for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) {
                          var itemWithSameName = itemsWithSameName_1[_i];
                          if (tryMerge(itemWithSameName, child)) {
                              return false;
                          }
                      }
                      itemsWithSameName.push(child);
                      return true;
                  }
                  else {
                      var itemWithSameName = itemsWithSameName;
                      if (tryMerge(itemWithSameName, child)) {
                          return false;
                      }
                      nameToItems[name] = [itemWithSameName, child];
                      return true;
                  }
                  function tryMerge(a, b) {
                      if (shouldReallyMerge(a.node, b.node)) {
                          merge(a, b);
                          return true;
                      }
                      return false;
                  }
              });
              /** a and b have the same name, but they may not be mergeable. */
              function shouldReallyMerge(a, b) {
                  return a.kind === b.kind && (a.kind !== 225 /* ModuleDeclaration */ || areSameModule(a, b));
                  // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes.
                  // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'!
                  function areSameModule(a, b) {
                      if (a.body.kind !== b.body.kind) {
                          return false;
                      }
                      if (a.body.kind !== 225 /* ModuleDeclaration */) {
                          return true;
                      }
                      return areSameModule(a.body, b.body);
                  }
              }
              /** Merge source into target. Source should be thrown away after this is called. */
              function merge(target, source) {
                  target.additionalNodes = target.additionalNodes || [];
                  target.additionalNodes.push(source.node);
                  if (source.additionalNodes) {
                      (_a = target.additionalNodes).push.apply(_a, source.additionalNodes);
                  }
                  target.children = ts.concatenate(target.children, source.children);
                  if (target.children) {
                      mergeChildren(target.children);
                      sortChildren(target.children);
                  }
                  var _a;
              }
          }