CarGurus interview question

Building of a tree structure