Merge pull request #4041 from erozenfeld/gtTreeHasSideEffectsFix