This is a simpler variant on D96647. It just adds a straightforward depth limit with a high cutoff, without introducing complex logic for BatchAA consistency. It accepts that we may cache a sub-optimal result if the depth limit is hit.
Eventually this should be more fully addressed by D96647 or similar, but in the meantime this avoids stack overflows in a cheap way.