fix the bug that the tree fails when empty