getNodeFromPath = (path, tree) => {
  let node;
  let nextLevel = tree;

  if (!Array.isArray(path)) {
    throw new Error('path is not an array');
  }

  for (let i = 0; i < path.length; i++) {
    const id = path[i];

    let nextNode = nextLevel.find(n => n.id === id);

    if (!nextNode) {
      throw new Error(`Could not find node at ${path.join(',')}`);
    }

    if (i === path.length - 1 && nextNode.id === id) {
      node = nextNode;
    } else {
      nextLevel = nextNode.children;
    }
  }

  if (!node) {
    throw new Error(`Could not find node at ${path.join(',')}`);
  }

  return node;
}
Gets a node in the original tree from a provided path.

@param {number|string[]} path - The id path to the node
@param {Object[]} tree - The Original tree