findAncestor

Search an element's ancestors, returning the first match found, if any.

For example, perhaps you're nested several levels below some outer container that's tagged by a class:

ElementTarget.findAncestor { it.classList.contains("outer-container") }