On Debian-based systems you can simply use debfoster (https://packages.debian.org/debfoster) to remove unwanted packages.
debfoster explicitly asks you which packages you want to keep and removes everything else. You can use it to strip down an existing Debian installation to just the base packages.