# Prior state dependent transition probability ABRACADABRA problem

The power of the martingale trick for computing the expected stopping time is amply demonstrated in this question and this answer as an advanced version of the ABRACADABRA problem. However, it seems to premise on the independence of the transition probability on the prior state. How can we modify the trick to deal with the case where the transition probability is prior state dependent, e.g., in the cited answer, the transition probabilities $$P(T\rightarrow H)\ne P(H\rightarrow H)$$ and $$P(T\rightarrow T)\ne P(H\rightarrow T)$$?