Fix bug with tree splicing.
Merge remote-tracking branch 'upstream/pr/1819' into runQuery