Apple interview question

Tree recursion problem