Refactor deep merge