code: private boolean isValidElement(CmsXmlPage page, String element) {
  
          CmsFile file = page.getFile();
          String template;
          try {
              template = getCms().readPropertyObject(
                  getCms().getSitePath(file),
                  CmsPropertyDefinition.PROPERTY_TEMPLATE,
                  true).getValue(null);
          } catch (CmsException e) {
              return false;
          }
  
          return isValidTemplateElement(template, element);
      }
docs: Checks if the selected new element is valid for the selected template.<p>
  
  @param page the xml page
  @param element the element name
  
  @return true if ALL_TEMPLATES selected or the element is valid for the selected template; otherwise false