function getFlatTreePredecessorNodes(tree, id) {
  var result = [];

  // 构建一个 id -> 节点 的映射
  var nodeMap = {};
  tree.forEach(function (node) {
    nodeMap[node.id] = node;
  });
  var currentNode = nodeMap[id];
  while (currentNode && currentNode.parentid) {
    var parentNode = nodeMap[currentNode.parentid];
    if (parentNode) {
      result.unshift(parentNode); // 确保父节点顺序从根到当前节点
      currentNode = parentNode;
    } else {
      break;
    }
  }
  return result;
}
export default getFlatTreePredecessorNodes;