In my opinion there is very little risk that a child's iPad will be used for monitoring an ex-spouse. The device would be more likely to record kiddie-level activity and almost nothing from the Mom because more often than not she is out of range. Your iPhone would be a much better target for an attacker!
Remember that spyware generally needs the attacker to have physical access to the device, and to know the passcode so permission to install can be granted. Granted, there are threats which can be installed remotely but they almost always need physical access to enter the passcode. There might be very few spyware apps which can be installed without needing a passcode to be entered, but they are generally very costly, restricted to government intelligence agencies and law enforcement, and not available for public users.
- Change the Apple ID password for the account used by the suspect device.
- Go to the Apple ID section of Settings (click/tap the top entry in the Settings list, Your Name) then scroll down and review the connected devices. Eliminate any which don't belong to you or daughter.
- Consider the risk, and whether it might be necessary to erase (Factory Reset) the suspect device and reinstall a clean operating system.
- Upgrade the iPadOS to the latest available and most secure version.
- Change the passcode for the suspect device. (the difficulty here is something a 9-yo will accept and remember, but not easily guessable). If the device has Touch ID, check and clean the list of enrolled fingerprints.
- Eliminate the risk of social engineering. Impress on the 9 year-old daughter that the passcode must NEVER be revealed to anyone. Any requests to get the passcode should be reported to Mom.
- Take appropriate steps to prevent ex-husband having any physical access to the device.
- Now remove the ability to transmit unwanted data from the device. If the device has cellular function, disable it and/or remove the SIM. Clean the known WiFi list (WiFi setup) so the only available external connection is your home (or other trusted/known) WiFi router.