avoid TypeError when root is nil