Treat undo history as a tree