public boolean contains(NamedPsiElement element, boolean leniant) {
PsiElement child = getFirstChild();
while (child != null) {
if (child instanceof NamedPsiElement) {
NamedPsiElement namedPsiElement = (NamedPsiElement) child;
if (namedPsiElement == element) {
return true;
}
}
child = child.getNextSibling();
}
if (leniant) {
child = getFirstChild();
while (child != null) {
if (child instanceof NamedPsiElement) {
NamedPsiElement namedPsiElement = (NamedPsiElement) child;
if (namedPsiElement.matches(element)) {
return true;
}
}
child = child.getNextSibling();
}