Isn't this what dom.isAncestor() does?