Weird glitces in Z and mist render layers

When I render objects in Cycles that use materials with alpha texture plugged in - I get these weird glitches in mist and depth passes.

Z and Mist render layers

Z and Mist render layers with alpha disabled

I found convoluted solutions in the internet how to get rid of these:
https://blender.stackexchange.com/questions/38111/what-causes-this-mist-pass-glitch

The earliest issue that I’ve found was addressed about 5 years ago.
However, I found a better solution - it seems like EEVEE doesn’t have problems rendering Z or mist passes.

Z and Mist passes rendered in EEVEE

But anyway, is this a bug or technical limitation of ray tracing renderers?

Seems like this problem still exists which makes working in production pretty cumbersome. Anyone have a solution (other than using Eevee) for this?

can you drop an example scene in here? there are a few things it could be, that are addressed in those articles. (transparency passes, incorrect shader setup, etc)