\begin{tikzpicture}
	\input{src/tikz/alsk}

	\begin{scope}[alsk/treestyle,
		alsk/tree/muscle/.append style={font=\footnotesize,minimum width=8mm,minimum height=3mm},
		alsk/tree/struct/.append style={font=\footnotesize,minimum width=12mm,minimum height=3mm},
		level distance=11mm, sibling distance=16mm,
		every node/.style=leaf,
	]
		\node[branch](farmsel1){farmsel\textsubscript{1}}
		child{ node[branch](serial1){serial\textsubscript{1}}
			child{ node(ch){HC} }
			child{ node[branch](serial2){serial\textsubscript{2}}
				child{ node(init ls){RLI} }
				child{ node[branch](itersel){itersel}
					child{ node[branch](farmsel2){farmsel\textsubscript{2}}
						child{ node[branch](serial3){serial\textsubscript{3}}
							child{ node(m){M} }
							child{ node(ls){RL} }
						}
						child{ node(sel3){Sel\textsubscript{3}} }
					}
					child{ node(sel2){Sel\textsubscript{2}} }
				}
			}
		}
		child{ node(sel1){Sel\textsubscript{1}} };
	\end{scope}

	% task count
	\path (farmsel1) -- node[left=2mm]{\only<4->{\footnotesize$a \times$}} (serial1);
	\path (farmsel2) -- node[left=2mm]{\only<6->{\footnotesize$b \times$}} (serial3);

	% identifiers
	\begin{scope}[
		->,dashed,rounded corners=1mm,
		frame/.style={draw,rectangle,rounded corners=1mm,dashed,fit=#1}
	]
		\coordinate (yline) at ($(farmsel1)+(30mm,0)$);

		\path[only on=<2->{draw}] (farmsel1) -- (farmsel1 -| yline) node(n9t){};
		\path[only on=<3->{draw}] (sel1) -- (sel1 -| yline) node(n9b){};

		\path[only on=<{4-7,10-}>{draw}] (serial1) |- ++(0,-5mm) -- (\curcoord -| yline) node(nat){};

		\visible<5-7,10->{
			\node[frame=(ch)(itersel)(farmsel2)(sel2)] (fserial1) {};
		}
		\path[only on=<{5-7,10-}>{draw}] (fserial1) -- (fserial1 -| yline) node(nfs1){};
		\path[only on=<{5-7,10-}>{draw}] (sel3) -- (sel3 -| yline) node(nab){};

		\path[only on=<{6-7,9-}>{draw}] (serial3) |- ++(0,-5mm) -- (\curcoord -| yline) node(nbt){};
		\visible<7,9->{
			\node[frame=(m)(ls)] (fserial3) {};
		}
		\path[only on=<{7,9-}>{draw}] (fserial3) -- (fserial3 -| yline) node(nbb){};
	\end{scope}

	\begin{scope}
		\only<2>{\node[right] at (n9t) {\num{1} exécution};}
		\only<4>{\node[right] at (nat) {$a$ exécutions parallèles};}
		\only<6>{\node[right] at (nbt) {$a \times b$ exécutions parallèles};}
	\end{scope}

	\begin{scope}[decoration={brace,amplitude=4pt,raise=4pt}]
		\visible<3-7,8->{
			\draw[decorate] (n9t.north) -- (n9b.south) node[midway,right=10pt]
			{\alt<3-7>{\num{1} exécution}{$\text{id} = 0$}};
		}
		\visible<5-7,10->{
			\draw[decorate] (nat.north) -- (nab.south) node[midway,right=10pt,only on=<10->{text justified}]
			{\alt<5-7>{$a$ exécutions parallèles}{$
			\begin{aligned}
				&\text{id} \in \{0, b, 2\,b, \dots, (a-1)\,b\}\\
				&\iff \text{id} \in b\,\llbracket 0, a \llbracket
			\end{aligned}
			$}};
		}
		\visible<7>{
			\draw[decorate] (nbt.north) -- (nbb.south) node[midway,right=10pt]
			{$a \times b$ exécutions parallèles};
		}
		\visible<9>{
			\draw[decorate] (nbt.north) -- (nbb.south) node[midway,right=10pt]
			{$\text{id} \in \llbracket 0, a\,b \llbracket$};
		}
		\visible<10->{
			\draw[decorate] (nbt.north) -- (nbb.south) node[midway,right=10pt]
			{$\text{id} \in \llbracket 0, a\,b \llbracket (= \displaystyle\bigcup^{a-1}_{k=0} \llbracket k\,b, (k+1)\,b-1 \rrbracket)$};
		}
	\end{scope}
\end{tikzpicture}
