does cleaning up only involve the IDO database backend, or is it about logs and configuration in a distributed setup as well?
Which data should be cleaned, only the one visible in the web interface or everything? Typically the main entry point in the schema are the object_ids which can be fetched from the icinga_objects table. Using this, you may iterate all tables, remember the foreign key (FK - host_object_id, service_object_id, etc.) and purge rows away. Depending on the size of your database, this may take quite a bit - test that up front and schedule a maintainance window for production then.