<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_controller(self, controller):
 """Remove child controller and destroy it Removes all references to the child controller and calls destroy() on the controller. :param str | ExtendedController controller: Either the child controller object itself or its registered name :return: Whether the controller was existing :rtype: bool """

        # Get name of controller
        if isinstance(controller, ExtendedController):
            # print(self.__class__.__name__, " remove ", controller.__class__.__name__)
            for key, child_controller in self.__child_controllers.items():
                if controller is child_controller:
                    break
            else:
                return False
        else:
            key = controller
        # print(self.__class__.__name__, " remove key ", key, self.__child_controllers.keys())
        if key in self.__child_controllers:
            if self.__shortcut_manager is not None:
                self.__action_registered_controllers.remove(self.__child_controllers[key])
                self.__child_controllers[key].unregister_actions(self.__shortcut_manager)
            self.__child_controllers[key].destroy()
            del self.__child_controllers[key]
            # print("removed", controller.__class__.__name__ if not isinstance(controller, str) else controller)
            return True
        # print("do not remove", controller.__class__.__name__)
        return False