Here you have the answer to your own question. Use apt-mark to mark the packages you want to keep and all "required" packages as "manual"ly installed. Then mark all other packages as "auto". Then let apt-get autoremove do its work.
After that, use e.g. aptitude to remove remaining configuration files with aptitude purge '~c' Regards, jvp.