plugin.js
function flattenTree(root) {
  let newChildren = [];
  root.children.forEach(child => {
    const commonParent = getDeepMoreThenOneChild(child);
    if (commonParent.children.length === 0) {
      newChildren.push(commonParent);
    } else {
      newChildren = newChildren.concat(commonParent.children);
    }
  });
  root.children = newChildren;
}
function flattenTree(root) {
  let newChildren = [];
  root.children.forEach(child => {
    const commonParent = getDeepMoreThenOneChild(child);
    if (commonParent.children.length === 0) {
      newChildren.push(commonParent);
    } else {
      newChildren = newChildren.concat(commonParent.children);
    }
  });
  root.children = newChildren;
}
function flattenTree ( root ) { let newChildren = [ ] ; root . children . forEach ( child => { const commonParent = getDeepMoreThenOneChild ( child ) ; if ( commonParent . children . length === 0 ) { newChildren . push ( commonParent ) ; } else { newChildren = newChildren . concat ( commonParent . children ) ; } } ) ; root . children = newChildren ; }
if root children have only on child we can flatten this
if root children have only on child we can flatten this