code: public ReadOnlyStyledDocument<PS, SEG, S> mapParagraphs(UnaryOperator<Paragraph<PS, SEG, S>> mapper) {
          int n = tree.getLeafCount();
          List<Paragraph<PS, SEG, S>> pars = new ArrayList<>(n);
          for(int i = 0; i < n; ++i) {
              pars.add(mapper.apply(tree.getLeaf(i)));
          }
          return new ReadOnlyStyledDocument<>(pars);
      }
docs: Maps all of this document's paragraphs using the given mapper and returns them in a new
  {@link ReadOnlyStyledDocument}.