Traslation of the algorithm provided by Mark
Reimplementation of the scattering diagrams framework