I still think this would be more readable like this:
```java

   private static final Text indentText = new Text("  ");

   @Override
   public void write(OutputStream output) throws IOException, WebApplicationException
   {
      @Cleanup
      Closeable closeable = (Closeable) (tuIter instanceof Closeable ? tuIter : NullCloseable.INSTANCE);
      @SuppressWarnings("null")
      PeekingIterator<TU> iter = Iterators.peekingIterator(tuIter);
      failIfWhateverCondition()
      
      Element tmx = new Element("tmx");
      tmx.addAttribute(new Attribute("version", "1.4"));
      Element header = exportStrategy.buildHeader();
      Element body = new Element("body");

      StreamSerializer tmxWriter = new StreamSerializer(output);
      tmxWriter.writeXMLDeclaration();
      tmxWriter.writeStartTag(tmx);
      indent(tmxWriter);
      tmxWriter.write(header);
      indent(tmxWriter);
      tmxWriter.writeStartTag(body);
      while (iter.hasNext())
      {
         Optional<Element> textUnit = exportStrategy.buildTU(iter.next());
         if (hasTranslations(textUnit))
         {
            tmxWriter.write(textUnit.get());
         }
      }
      indent(tmxWriter);
      tmxWriter.writeEndTag(body);
      tmxWriter.writeEndTag(tmx);

      tmxWriter.flush();
   }
   
   private static void failIfWhateverCondition(PeekingIterator<TU> iter) throws Something
   {
      // Fetch the first result, so that we can fail fast, before
      // writing any output. This should enable RESTEasy to return an
      // error instead of simply aborting the output stream.
      if (iter.hasNext()) iter.peek();
   }

   private static void indent(StreamSerializer writer)
   {
      writer.writeInline(indentText);
   }
   
   private static boolean hasTranslations(Optional<Element> textUnit)
   {
      // If there aren't any translations for this TU, we shouldn't include it.
      // From the TMX spec: "Logically, a complete translation-memory
      // database will contain at least two <tuv> elements in each translation
      // unit."
      return textUnit.isPresent() && textUnit.get().getChildElements("tuv").size() >= 2;
   }
```