private void onAdd(boolean child) {
    String ext = StringUtil.notNullize(JBIterable.from(IdeLanguageCustomization.getInstance().getPrimaryIdeLanguages())
      .filterMap(Language::getAssociatedFileType)
      .filterMap(FileType::getDefaultExtension)
      .first(), "txt");
    FileTemplateBase selected = ObjectUtils.tryCast(getSelectedTemplate(), FileTemplateBase.class);
    if (selected == null && child) return;
    String name = child ? selected.getChildName(selected.getChildren().length) : IdeBundle.message("template.unnamed");
    FileTemplate template = createTemplate(name, ext, "", child);
    if (child) {
      selected.addChild(template);
    }
  }
private void onAdd(boolean child)