Optiver interview question

Tree traversals with a constraint