Matlab code to derive the overall difference equation relating two systems
Sure:

\$    z[n] + az[n−N] = y[n] \$

now lets take the above equation and substitute  x[n]=z[n]

\$    x[n] + ax[n−N] = y[n] \$

which looks exactly like the other equation, so they are equivalent