Remove unused items?

Is there any way to launch a kind of “cleaner” to remove non used items (sensors, switches or whatever) from configs?
I’ve a lot of old entries on logook, history and template configs, and it would be very annoying to removes manually.