binary tree serialize and deserialize