This can be achieved by using the built-in inspection Java | Declaration redundancy | Unused declaration.
To run it on whole project go to Code -> Analyze -> Run inspection by name..., type Unused declaration and select desired scope.
Then carefully check output and mark some classes as entry points if needed.
Now you can select Unused declaration node in list and perform Safe delete action on all unused declarations at once.

For Kotlin there is similar inspection Kotlin | Redundant constructs | Unused symbol.