fix handling of empty tree