An algorithm for solving systems of quadratic equations in branching processes