What is the intuition behind Progressive hedging algorithm?

I am reading some papers about PHA to solve multi-stage stochastic programming, but I think it is not still clear to me. This is my understanding and I would be thankful to know if it is correct or not. When have non-anticipativity constraints, all scenarios are linked and we cannot decompose the problem. So, we decompose all non-anticipativity constraints and solve the problem for each scenario. In this situation, the value of decision variables used in non-anticipativity and first-stage decision variables might be different. So, we penalize the deviation from the average. I have a non-anticipativity constraints as follows:

$$p_{jts} = p_{jts^{\prime}} \quad \forall j,t,s,s^{\prime} \in S: (\xi_1^s,\dots,\xi_{t-1}^s)=(\xi_1^{s^\prime},\dots,\xi_{t-1}^{s^\prime})$$

One thing that is not clear to me is how to penalize the deviation for this constraint? I have defined a variable $$\Xi_{t,s,s^{\prime}}$$ which takes 1 if $$(\xi_1^s,\dots,\xi_{t-1}^s)=(\xi_1^{s^\prime},\dots,\xi_{t-1}^{s^\prime})$$. Can I use the following constraint as the penalty? $$\sum_{j}\sum_{t}\sum_{s}|p_{jts}-\bar{p}_{jts}|$$

where $$\bar{p}_{jts} = \frac{\sum_{s^{\prime}}\Xi_{tss^{\prime}}.p_{jts^{\prime}}.pr_{s^{\prime}}}{\sum_{s^{\prime}}\Xi_{tss^{\prime}}.pr_{s^{\prime}}}$$

$$\bar{p}_{jts}$$ will be equal to $$\bar{p}_{jts^{\prime}}$$ is $$\Xi_{tss^{\prime}}.p_{jts^{\prime}}=1$$.

Moreover, if $$y_j$$ is the first-stage decision variable, I should add the following term into the objective function:

$$\sum_{j}|y_j-\bar{y}_j| \quad \text{where} \quad \bar{y}_j= \sum_{s}pr_s.y_{js}$$.

I think most papers use fan of scenarios and node-by-node to develop PHA. However, I am willing to use $$\Xi_{tss^{\prime}}$$ to define the algorithm which is based on the scenario tree. If someone has a clear pseudo-code of PHA for multi-stage algorithm, I will be thankful if you can share it.