Merge repl and rt versions of wait until AAE trees build

Craziness in the 1.4 branch made us end up with two versions of wait_until_aae_trees_built. I did not merge them when rushing to finish a 1.4 release, but now I need to pay my debt.  I should have the PR out soonish.