code: function(next, data, options) {
          // eslint-disable-next-line no-undef
          var isFalseCache = typeof WeakSet !== "undefined" ? new WeakSet() : null;
          var adapter = options.adapter;
  
          return function descendant(elem) {
              var found = false;
  
              while (!found && (elem = adapter.getParent(elem))) {
                  if (!isFalseCache || !isFalseCache.has(elem)) {
                      found = next(elem);
                      if (!found && isFalseCache) {
                          isFalseCache.add(elem);
                      }
                  }
              }
  
              return found;
          };
      }
docs: traversal