code: function topLevelNodeAt(node, top) {
      while (node && node.parentNode != top)
        node = node.parentNode;
      return node;
    }
docs: Find the 'top-level' (defined as 'a direct child of the node passed as the top argument') node that the given node is contained in. Return null if the given node is not inside the top node.