Fix bug for empty tree