function flattenTree(deepTree) {
  var result = [];
  function traverse(node) {
    var parentId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
    node.forEach(function (item) {
      var id = item.id,
        name = item.name,
        _item$children = item.children,
        children = _item$children === void 0 ? [] : _item$children;
      result.push({
        id: id,
        name: name,
        parentid: parentId
      });
      if (Array.isArray(children) && children.length > 0) {
        traverse(children, id);
      }
    });
  }
  traverse(deepTree);
  return result;
}
export default flattenTree;