public static void writeExternalTemplate(@NotNull PostfixTemplate template, @NotNull Element parentElement) {
    if (template instanceof EditablePostfixTemplateWithMultipleExpressions) {
      parentElement.setAttribute(TOPMOST_ATTR, String.valueOf(((EditablePostfixTemplateWithMultipleExpressions<?>)template).isUseTopmostExpression()));
      Element conditionsTag = new Element(CONDITIONS_TAG);

      //noinspection unchecked
      Set<? extends PostfixTemplateExpressionCondition<? extends PsiElement>> conditions =
        (Set<? extends PostfixTemplateExpressionCondition<? extends PsiElement>>)((EditablePostfixTemplateWithMultipleExpressions)template)
          .getExpressionConditions();

      for (PostfixTemplateExpressionCondition<? extends PsiElement> condition : conditions) {
        Element element = new Element(CONDITION_TAG);
        condition.serializeTo(element);
        conditionsTag.addContent(element);
      }
      parentElement.addContent(conditionsTag);
    }

    Element templateTag = TemplateSettings.serializeTemplate(((EditablePostfixTemplate)template).getLiveTemplate(), null,
                                                             LazyKt.lazyOf(Collections.emptyMap()));
    parentElement.addContent(templateTag);
  }
public static void writeExternalTemplate(@NotNull PostfixTemplate template, @NotNull Element parentElement)