Which solver/model library can be used recursively / reentrantly

Thank you for your help and time. I figured out there is a way how to rewrite it differently and more easily which makes this question pointless.