Skip to content

getParentOfTypeAndBranches

inline fun <reified T : PsiElement> PsiElement.getParentOfTypeAndBranches(strict: Boolean = false, noinline branches: T.() -> Iterable<PsiElement?>): T?

Checks the nearest element of type T and returns it if this element lies within any subtree selected by branches. If none of that candidate's branches contain this element, returns null without checking higher ancestors. When strict is false, this element itself is also considered as the candidate.