Fix depth-first search branch pruning