Given a binary tree representing a system hierarchy, write a routine to serialize and deserialize the tree to minimize transmission payload size.