changing compare- functions to do depth-first