Let's set some conventions to begin with. Scattering matrix is given by
$$
S = \begin{pmatrix}
r'& t \\
t'& r
\end{pmatrix}
$$
Where, the reflection and transmission is given as below:
[![enter image description here][1]][1]
Now introduce two scattering matrices $S_1$ and $S_2$ defined as
$$
S_i = \begin{pmatrix}
r_i'& t_i \\
t'_i& r_i
\end{pmatrix}
$$
The composed scattering matrix is $S_{12} = S_1 \circ S_2$
[![enter image description here][2]][2]
One needs to consider infinite number of reflection and transmissions in between the scattering matrices as below from both left and right directions 
as below (here I have made the assumption that the modes don't get a phase, otherwise one needs to carry a phase factor also):
[![enter image description here][3]][3]
The effective transmission and reflection coefficients of $S_{12}$ are given by:
[![enter image description here][4]][4]

One can then take a series of scattering matrix and perform pairwise compositions. Note that the composition is associative.


  [1]: https://i.sstatic.net/Dypsx.png
  [2]: https://i.sstatic.net/iFgPc.png
  [3]: https://i.sstatic.net/RI0Hk.png
  [4]: https://i.sstatic.net/Hg5aS.png