Serialize and deserialize
Write the tree level by level with a queue, N for every missing child; reading the tokens back in the same order, every polled node takes the next two as its children.
Write the tree level by level with a queue, N for every missing child; reading the tokens back in the same order, every polled node takes the next two as its children.