- return testNode(level, index, text), true
+ return treeTestNode(level, index, text), true, nil
+}
+
+// viewPush adds state to the newest end of states and returns the new list. An
+// empty list gets one entry. When the newest entry is not kept, it becomes kept
+// with its own state, and state is dropped. When it is kept, state becomes a
+// new newest entry, and the state of the old newest entry goes to the older
+// entries by the same push.
+func viewPush(state int, states *ViewPushEntry) *ViewPushEntry {
+ if states == nil {
+ return &ViewPushEntry{
+ state: state,
+ }
+ }
+
+ if !states.keep {
+ return &ViewPushEntry{
+ keep: true,
+ state: states.state,
+ older: states.older,
+ }
+ }
+
+ return &ViewPushEntry{
+ state: state,
+ older: viewPush(states.state, states.older),
+ }