Fix code duplication in Scene::IsUniqueName.