When trying to make the hirachical structure of an itemize environment more "visible" I found this nice answer from @schtandard to the original question Make itemize look like dirtree:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{tikz}
\makeatletter
\newlist{treelist}{itemize}{5}
\setlist[treelist]{label=\treelist@label}
\tikzset{treelist line/.style={thick, line cap=round, rounded corners}}
\def\treelist@label{%
\begin{tikzpicture}[remember picture, baseline={([yshift=-.6ex] treelist-bullet-\the\enit@depth.center)}]
\draw [treelist line] (0, 0) -- node (treelist-bullet-\the\enit@depth) {} ++(.5em, 0);
\end{tikzpicture}%
\ifnum\enit@depth>1
\tikz[remember picture, overlay] \draw [treelist line] (treelist-bullet-\the\numexpr\enit@depth-1\relax.center) |- (treelist-bullet-\the\enit@depth.center);%
\fi
}
\makeatother
\begin{document}
\begin{treelist}
\item
Gas ideal (partículas idénticas que no interactúan, i.e.~la energía no tiene términos cruzados).
\begin{treelist}
\item
Fermiones.
\begin{treelist}
\item
Límite de gas no degenerado.
Corresponde a temperaturas muy altas y densidades muy bajas, el resultado es el gas ideal clásico.
\item
Límite de gas degenerado.
Es lo opuesto, temperaturas bajas y densidades altas.
Aparece Pauli con su principio de exclusión.
\begin{treelist}
\item
Enanas blancas.
\end{treelist}
\end{treelist}
\item
Bosones.
\begin{treelist}
\item
Límite de gas no degenerado.
Corresponde a temperaturas muy altas y densidades muy bajas, el resultado es el gas ideal clásico.
\begin{treelist}
\item
Gas de fotones.
\item
Gas de fonones.
\end{treelist}
\item
Límite de gas degenerado.
Básicamente es un condensado de Bose-Einstein.
\begin{treelist}
\item
Superfluidos.
\item
Superconductores.
\end{treelist}
\end{treelist}
\end{treelist}
\item
Otros temas que no sean gas ideal. No vimos nada, creo.
\end{treelist}
\end{document}
Unfortunately I've got a lot of items to show and the connecting lines get lost when a page break occures. I found another post from @Schrödinger's cat showing how to get an arrow spanning between annotations over multiple pages:
\documentclass[10pt,oneside]{scrbook}
\usepackage{lipsum}
\usepackage[left=32.5mm, right=22.5mm, top=25mm, bottom=20mm, marginparsep=3mm]{geometry}
\usepackage{tikzpagenodes}
\usepackage{eso-pic}
\usetikzlibrary{tikzmark}
\usepackage{marginnote}
\renewcommand*{\marginfont}{\footnotesize\itshape}
\makeatletter
\newcommand\PageOfTikzmark[1]{%
\csname save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname\endcsname}
\makeatother
\newcommand{\ConnectTikZmarknodes}[3][]{\AddToShipoutPictureFG{%
\begin{tikzpicture}[remember picture, overlay, shorten >=1.5mm,
shorten <=1.5mm,#1]
\iftikzmark{#2}{\edef\pageA{\PageOfTikzmark{#2}}}{\edef\pageA{-1}}%
\iftikzmark{#3}{\edef\pageB{\PageOfTikzmark{#3}}}{\edef\pageB{-1}}%
\iftikzmarkoncurrentpage{#2}
\edef\myflag{1}%
\else
\edef\myflag{0}%
\fi
\iftikzmarkoncurrentpage{#3}
\edef\myflag{\the\numexpr\myflag+2}%
\fi
\ifcase\myflag
\or
\draw[-] ([xshift=10pt]#2.south west)
to ([xshift=10pt]#2.south west|-current page text area.south);
\or
\draw[->] ([xshift=10pt]#3.north west|-current page text area.north)
to ([xshift=10pt]#3.north west);
\or
\draw[->] ([xshift=10pt]#2.south west)
to ([xshift=10pt]#3.north west);
\fi
\ifnum\value{page}>\pageA
\ifnum\value{page}<\pageB
\draw ([xshift=20pt]current page text area.north east) to
([xshift=20pt]current page text area.south east);
\fi
\fi
\end{tikzpicture}}}
\begin{document}
\marginnote{\tikzmarknode{a}{Thermoplast}}
\lipsum[1]
\marginnote{\tikzmarknode{b}{teilkristallin}}
\ConnectTikZmarknodes{a}{b}
\lipsum[1]
\marginnote{\tikzmarknode{c}{aliphatisch}}
\ConnectTikZmarknodes{b}{c}
\lipsum[1-7] % works fine
\marginnote{\tikzmarknode{d}{aliphatisch}}
\ConnectTikZmarknodes{c}{d}
\ConnectTikZmarknodes{d}{e}
\lipsum[1-23]
\marginnote{\tikzmarknode{e}{unproblematisch}}
\end{document}
So my question is: is it possible to combine these two solutions? How could I make the connections of a treelist spanning over page breaks?
Could anybody help? Thanks in advance for your efforts.
EDIT:
@Schrödinger's cat provided a good solution. But I missed to point out that there may be multiple connections crossing the page break. As can be seen from the following picture there should be a connection downwards from "Ferminons" to "Non-degenerate Fermi gas" and "Quasi-degenerate Fermi gas".

The corresponding code is:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc,tikzmark}
\makeatletter
\newcommand\PageOfTikzmark[1]{%
\csname save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname\endcsname}
\newlist{treelist}{itemize}{5}
\setlist[treelist]{label=\treelist@label}
\tikzset{treelist line/.style={thick, line cap=round, rounded corners},
treelist cutoff/.initial=3\baselineskip}
\def\treelist@label{%
\tikzmarknode{treelist-\the\enit@depth}{\textbullet}%
\ifnum\enit@depth>1\relax
\iftikzmark{treelist-\the\numexpr\enit@depth-1}{%
\begin{tikzpicture}[remember picture, overlay]
\draw let \p1=(treelist-\the\enit@depth),
\p2=(treelist-\the\numexpr\enit@depth-1)
in
\ifdim\y2>\y1
(treelist-\the\enit@depth) -|
(treelist-\the\numexpr\enit@depth-1\relax);
\else
(treelist-\the\enit@depth) -|
(treelist-\the\numexpr\enit@depth-1\relax|-current page text area.north);
\fi;
\draw let \p1=($(treelist-\the\enit@depth)-(current page text area.south)$)
in
\ifdim\y1<\pgfkeysvalueof{/tikz/treelist cutoff}
(treelist-\the\enit@depth) -|
(treelist-\the\numexpr\enit@depth-1\relax|-current page text area.south);
\fi;
\end{tikzpicture}%
}{%
}%
\fi
}
\makeatother
\begin{document}
\begin{treelist}
\item Ideal gas of noninteracting particles.
\begin{treelist}
\item
Fermions.
\begin{treelist}
\item Non--degenerate Fermi gas. The Pauli principle plays no major
role.
\item Quasi--degenerate Fermi gas. The Pauli principle is important
and dictates the occupation number.
\begin{treelist}
\item
Whatever.
\end{treelist}
\end{treelist}
\item
Bosons.
\begin{treelist}
\item Non--degenerate Bose gas.
\begin{treelist}
\item Photons.
\item Phonons.
\end{treelist}
\item Quasi--degenerate Bose gas.
Bose--Einstein condensation.
\begin{treelist}
\item
Superfluids.
\item
Superconductors.
\end{treelist}
\end{treelist}
\end{treelist}
\item Ti\emph{k}Zlings
\begin{treelist}
\item Anteater
\item Bear
\item Bee
\item Cat
\item Coati
\item Hippo
\item Koala
\item Marmot
\item Mole
\item Mouse
\item Panda
\item Penguin
\item Pig
\item Rhino
\item Sloth
\item Squirrel
\item Snowman
\end{treelist}
\item Ideal gas of noninteracting particles.
\begin{treelist}
\item
Fermions.
\begin{treelist}
\item Non--degenerate Fermi gas. The Pauli principle plays no major
role.
\item Quasi--degenerate Fermi gas. The Pauli principle is important
and dictates the occupation number.
\begin{treelist}
\item
Whatever.
\end{treelist}
\end{treelist}
\item
Bosons.
\begin{treelist}
\item Non--degenerate Bose gas.
\begin{treelist}
\item Photons.
\item Phonons.
\end{treelist}
\item Quasi--degenerate Bose gas.
Bose--Einstein condensation.
\begin{treelist}
\item
Superfluids.
\item
Superconductors.
\end{treelist}
\end{treelist}
\end{treelist}
\end{treelist}
\end{document}
As far as I understand a node is put around each list label. By checking if there is a node with a lower depth value a connection could be established. Depending on the y-coordinate of the node a line is drawn to the node with the lower depth value or to the "current page text area.south"/"current page text area.north"-nodes. But this seems to cause some problems with the nested treelists as shown above.
