code: function isParent(possibleParent, elem) {
      if(!elem || elem.nodeName === 'HTML') {
        return false;
      }
  
      if(elem.parentNode === possibleParent) {
        return true;
      }
  
      return isParent(possibleParent, elem.parentNode);
    }
docs: Check if a node is parent to another node