Let $X$ be a non-negative integer-valued random variable with probability mass function $f(k)=P(X=k)$ for $k=0,1,2,\ldots$ Define a function $h(r) = P(X=r | X \geq r)$. Let $U_i$ for $i=0,1,2,\ldots$ be a sequence of i.i.d. random variable uniformly distributed over $[0,1]$.
Find the distribution of $Z=\min \{n: U_n \leq h(n) \}$.