Fix integersr,s1,…,slr,s_{1},\dots ,s_{l}such that1≤l≤r−11\leq l\leq r-1andsl≥r−l+1s_{l}\geq r-l+1, and letC(r;s1,…,sl)\mathcal {C}(r;s_{1},\dots ,s_{l})be the set of all integral, projective and nondegenerate curvesCCof degrees1s_{1}in the projective spacePr\mathbf {P}^{r}, such that, for alli=2,…,li=2,\dots ,l,CCdoes not lie on any integral, projective and nondegenerate variety of dimensioniiand degree>si>s_{i}. We say that a curveCCsatisfies theflag condition(r;s1,…,sl)(r;s_{1},\dots ,s_{l})ifCCbelongs toC(r;s1,…,sl)\mathcal {C}(r;s_{1},\dots ,s_{l}). DefineG(r;s1,…,sl)=max{pa(C):C∈C(r;s1,…,sl)},G(r;s_{1},\dots ,s_{l})=\operatorname {max}\left \{p_{a}(C):\,C\in \mathcal {C}(r;s_{1},\dots ,s_{l})\right \},wherepa(C)p_{a}(C)denotes the arithmetic genus ofCC. In the present paper, under the hypothesiss1≫⋯≫sls_{1}\gg \dots \gg s_{l}, we prove that a curveCCsatisfying the flag condition(r;s1,…,sl)(r;s_{1},\dots ,s_{l})and of maximal arithmetic genuspa(C)=G(r;s1,…,sl)p_{a}(C)=G(r;s_{1},\dots ,s_{l})must lie on a unique flag such asC=Vs11⊂Vs22⊂⋯⊂Vsll⊂PrC=V_{s_{1}}^{1}\subset V_{s_{2}}^{2}\subset \dots \subset V_{s_{l}}^{l}\subset {\mathbf {P}^{r}}, where, for anyi=1,…,li=1,\dots ,l,VsiiV_{s_{i}}^{i}denotes an integral projective subvariety ofPr{\mathbf {P}^{r}}of degreesis_{i}and dimensionii, such that its general linear curve section satisfies the flag condition(r−i+1;si,…,sl)(r-i+1;s_{i},\dots ,s_{l})and has maximal arithmetic genusG(r−i+1;si,…,sl)G(r-i+1;s_{i},\dots ,s_{l}). This proves the existence of a sort of a hierarchical structure of the family of curves with maximal genus verifying flag conditions.