private static int getBlockElementIndex(@NotNull PsiElement element) {
    int i = 0;
    for (PsiElement sibling : element.getParent().getChildren()) {
      if (element.equals(sibling)) {
        return i;
      }
      if (isBlockElement(sibling)) {
        i++;
      }
    }
    throw new RuntimeException("Malformed PSI");
  }
private static int getBlockElementIndex(@NotNull PsiElement element)