  Extending Stallings' foldings of trees, we show in this article that every
parallel-preserving map between median graphs factors as an isometric embedding
through a sequence of elementary transformations which we call foldings and
swellings. This new construction proposes a unified point of view on Beeker and
Lazarovich's work on folding pocsets and on Ben-Zvi, Kropholler, and Lyman's
work on folding nonpositively curved cube complexes.
