Binance interview question

Tree traversal question using javascript