Transition metal nitrides have attracted much interest of the scientific community for their intriguing properties and technological applications. Here we focus on yttrium dinitride (YN$_{2}$) and its formation and structural transition under pressure. We employed a fixed composition USPEX search to find the most stable polymorphs. We choose yttrium as a proxy for the lanthanide series because it has only $+3$ oxidation state, contrary to most transition metals. We then computed thermodynamic and dynamical stability of these structures compared to the decomposition reactions and we found that the compound undergoes two structural transitions, the latter showing the formation N$_{4}$ chains. A closer look into the nature of the nitrogen bonding showed that in the first two structures, where nitrogen forms dimers, the bond length is intermediate between that of a single bond and that of a double bond, making it hard to rationalize the proper oxidation state configuration for YN$_{2}$. In the latter structure where there is the formation of N$_{4}$ chains, the bond lengths increase significantly, up to a value that can be justified as a single bond. Finally, we also studied the electronic structure and the dynamical stability of the structures we found.