code: function getClosest(el, validateWith, onlyParent) {
        if (angular.isString(validateWith)) {
          var tagName = validateWith.toUpperCase();
          validateWith = function(el) {
            return el.nodeName.toUpperCase() === tagName;
          };
        }
  
        if (el instanceof angular.element) el = el[0];
        if (onlyParent) el = el.parentNode;
        if (!el) return null;
  
        do {
          if (validateWith(el)) {
            return el;
          }
        } while (el = el.parentNode);
  
        return null;
      }
docs: getClosest replicates jQuery.closest() to walk up the DOM tree until it finds a matching
  nodeName.
  
  @param {Node} el Element to start walking the DOM from
  @param {string|function} validateWith If a string is passed, it will be evaluated against
  each of the parent nodes' tag name. If a function is passed, the loop will call it with each
  of the parents and will use the return value to determine whether the node is a match.
  @param {boolean=} onlyParent Only start checking from the parent element, not `el`.
  @returns {Node|null} closest matching parent Node or null if not found