Fixed issues with tree-iterator, updated tests and code