Binary search tree serialization