Simplify a condition in search()

And rearrange best value update in case of SpNode.

No functional change.