Tripadvisor interview question

Tree paths and searching