serialize/deserialize tree