public static int countChildrenOfType(@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;
  }
public static int countChildrenOfType(@NotNull PsiElement element, @NotNull Class<? extends PsiElement> clazz)