Figured out policy expansion for a tree.

Unfortunately it means i turned scala from immutable and simple to mutable and convoluted...
I used all my own stacks.