code: function findChildContainingNode(root, node) {
    const parentNode = node.parentNode;
    return parentNode === root ?
      node :
      findChildContainingNode(root, parentNode);
  }
docs: Find the child of root that is or contains the given node.