isAncestor = function(ancestor) { var check = function(descendant) { var p = descendant && descendant.parentNode return ancestor === p || !!(p && check(p)) }; return check }