Fixed empty tree bug
(cherry picked from commit b36da5ec0ba5cf4a21d23edc8fe0484f586fb286)