For a given DOM element, find the first ancestor that matches a given CSS selector.