function hasParentNode (elem, parent) {
  let e = elem ? elem.parentNode : undefined

  while (e) {
    if (e === parent) {
      return true
    }
    e = e.parentNode
  }

  return false
}
Test whether an element has the provided parent node somewhere up the node tree.
@param {Element} elem
@param {Element} parent
@return {boolean}