Write a resumable tree explorer. Explore branches in order of priority product, such that the exploration priority of each node is the product of its priority with that of all its parents. The priorities of branches can change during exploration. Take a configuration flag as to whether to use ancestor priorities seen at time of discovery or instead to update them when changed. Use optimization techniques to prevent explosive looping if needed.