binary depth first search