+=over 4
+
+=item *
+
+The first one contains the header lines to include between the C<\documentclass> and the C<\begin{document}>.
+
+=item *
+
+The second one contains the mod declaration lines to put inside the document, between C<\begin{document}> and C<\end{document}>.
+
+=item *
+
+Finally, there's one array reference for each given TikZ set, which contain the lines for the actual TikZ pictures.
+
+=back
+
+ my ($header, $declarations, $seq1_body, $seq2_body) = $formatter->render($set1, $set2);
+
+=cut
+
+my $find_mods = do {
+ our %seen;
+
+ my $find_mods_rec;
+ $find_mods_rec = do {
+ no warnings 'recursion';
+
+ Sub::Name::subname('find_mods_rec' => sub {
+ my ($set, $layers, $others) = @_;
+
+ for ($set->mods) {
+ my $tag = $_->tag;
+ next if $seen{$tag}++;
+
+ if ($_->isa('LaTeX::TikZ::Mod::Layer')) {
+ push @$layers, $_;
+ } else {
+ push @$others, $_;
+ }