FIX: Uncaught TypeError: Object #<Object> has no method 'toTree'

Moved merge into feature branch and added tests.