serialization and deserialization of binary tree