Add tree serialize and deserialize