Hierarchical Model for Time Series with GaussianRandomWalk

I’m trying to approach for the first time Probabilistic Programming, what i want to do is create a hierarchical model for time series. I’m starting with this simple following model:

sigma_Z= pm.Uniform('sigma_Z', 0,3)
Z = pm.GaussianRandomWalk('Z', sd=sigma_Z, shape=N)
sigma_X = pm.Uniform('sigma_X', 0,3)
X = pm.Normal('X', Z[tt_i], sigma_X, observed=x)
trace = pm.sample()

Schermata%20del%202018-05-29%2021-34-43
How can I extend the model adding another layer above the Z?
In other words, i want add another Latent Variable Y, with each z_i is conditioned from y_i in order to create a hierarchical model.

It depends on what kind of conditioning you are speaking about. You can either encode the conditioning as a parameter to input into the definition of Z, or treat the Z and the additional Latent Variable Y as input to some function to get a new Z' = f(Z, Y) \sim \pi(Z, Y).