  The celebrated Stallings' decomposition theorem states that the splitting of
a finite index subgroup $H$ of a finitely generated group $G$ as an amalgamated
free product or an HNN-extension over a finite group implies the same for $G$.
We generalize the pro-$p$ version of it proved by Weigel and the second author
to splittings over infinite pro-$p$ groups. This generalization does not have
any abstract analogs. We also prove that generalized accessibility of finitely
generated pro-$p$ groups is closed for commensurability.
