Implement branching history datastructure.