prevState
cleaner and more modular tree merging