Meta interview question

Please see above. Tree traversal and sorting