fix depth first search on valid placement