code: function flattenNodeGenerator(node, parent, index, settings, stack) {
    const { itemsKey, idKey } = settings;
  
    return function flattenNode(list) {
      node = settings.initNode(node);
      node[idKey] = node[idKey] || settings.generateUniqueId();
      list.push(node);
  
      if (node[itemsKey]) {
        for (let i = 0, len = node[itemsKey].length; i < len; i++) {
          stack.push(
            flattenNodeGenerator(
              node[itemsKey][i],
              node,
              i,
              settings,
              stack
            )
          );
        }
      }
  
      if (parent && parent[itemsKey]) {
        // Records children' id
        parent[itemsKey][index] = node[idKey];
        node.parent = parent[idKey];
      }
  
      return list;
    };
  }
docs: Recursive node
  
  @param {Object} node - Object node
  @param {Object|String} parent - parent node
  @param {Number} index - chilren index
  @param {Object} settings - config settings
  @param {Array} stack - data stack
  @return {Function} Recursive function