Add nil check

https://github.com/appium/appium-uiauto/pull/39