code: private static boolean isPageInTemplateDefinition(Page page) {
      Resource resource = page.adaptTo(Resource.class);
      if (resource != null) {
        Resource parent = resource.getParent();
        if (parent != null) {
          return StringUtils.equals(NT_TEMPLATE, parent.getValueMap().get(JCR_PRIMARYTYPE, String.class));
        }
      }
      return false;
    }
docs: Checks if the given page is part of the editable template definition itself.
  @param page Page
  @return true if page is part of template definition.