A general algorithm to compute the steady-state solution of product-form cooperating Markov chains