add tree state saving