Adding a utility function for rewriting recursive calls as assignments.