int (@NotNull PsiElement element, @NotNull Class<? extends PsiElement> clazz) { int result = 0; for (PsiElement cur = element.getFirstChild(); cur != null; cur = cur.getNextSibling()) { if (clazz.isInstance(cur)) { result++; } } return result; }