Supporting more complicated child controller hierarchy

Previous code assumed that tabs are UINavigationControllers, this fix
supports any intermidiate controllers between a navigation and the tab
controller.