Using this answer requires that you create and maintain a file that contains the package names you want installed on your system. If you don't have one already, use the following command and delete the package names what you don't want to keep installed.
brew leaves > brew_packages
Then you can remove all installed, but unwanted packages and any unnecessary dependencies by running the following command
brew_clean brew_packages
brew_clean
is available here: https://gist.github.com/cskeeters/10ff1295bca93808213d
This script gets all of the packages you specified in brew_packages and all of their dependancies and compares them against the output of brew list
and finally removes the unwanted packages after verifying this list with the user.
At this point if you want to remove package a
, you simply remove it from the brew_packages file then re-run brew_clean brew_packages
. It will remove b
, but not c
.