function addValueColumnNodes(nodes, valueColumns) {
  const leafNodes = valueColumns.map(column => ({
    value: column.display_name,
    children: [],
    isValueColumn: true,
  }));
  if (nodes.length === 0) {
    return leafNodes;
  }
  if (valueColumns.length <= 1) {
    return nodes;
  }
  function updateNode(node) {
    const children =
      node.children.length === 0 ? leafNodes : node.children.map(updateNode);
    return { ...node, children };
  }
  return nodes.map(updateNode);
}
// or if there are no columns pivoted to the top header.
or if there are no columns pivoted to the top header.
or if there are no columns pivoted to the top header .
function addValueColumnNodes(nodes, valueColumns) {
  const leafNodes = valueColumns.map(column => ({
    value: column.display_name,
    children: [],
    isValueColumn: true,
  }));
  if (nodes.length === 0) {
    return leafNodes;
  }
  if (valueColumns.length <= 1) {
    return nodes;
  }
  function updateNode(node) {
    const children =
      node.children.length === 0 ? leafNodes : node.children.map(updateNode);
    return { ...node, children };
  }
  return nodes.map(updateNode);
}
function addValueColumnNodes ( nodes , valueColumns ) { const leafNodes = valueColumns . map ( column => ( { value : column . display_name , children : [ ] , isValueColumn : true , } ) ) ; if ( nodes . length === 0 ) { return leafNodes ; } if ( valueColumns . length <= 1 ) { return nodes ; } function updateNode ( node ) { const children = node . children . length === 0 ? leafNodes : node . children . map ( updateNode ) ; return { ... node , children } ; } return nodes . map ( updateNode ) ; }
or if there are no columns pivoted to the top header.
or if there are no columns pivoted to the top header .