According to an engine, a mate in X moves = +infinity, since it is a forced win for it.
Also according to an engine, a mate in X+Y moves = +infinity, since it's a forced win (just more moves, but an engine doesn't care about this).
Due to the pruning in the minimax algorithm, if the engine first examines the "mate in X+Y moves" branch, it will see it's a forced win and then prune all the other branches.
Due to this pruning, it wouldn't examine the mate in X moves branch.
However, engines like Stockfish always rank a mate in X moves above a mate in X+Y moves. I refuse to believe these engines always know intuitively which branch to look at first (if this was the case, then the engines would first look at the mate in X moves branch first, and then prune the rest, which would make sense).
Question: Given this, how do engines always rank a forced win/mate in X above a forced win/mate in X+Y, if they sometimes look at the latter first?