Update replace_with_ for quants methods to not use recursion (#42711)
* Fix replace
* fix bnb
* fix
* style
* fix
* fix
* styke
* fix
* style
* Apply suggestions from code review
Co-authored-by: Mohamed Mekkouri <93391238+MekkCyber@users.noreply.github.com>
---------
Co-authored-by: Mohamed Mekkouri <93391238+MekkCyber@users.noreply.github.com>