Add commit function which switches between root nodes