Remove package's dependencies (does not remove package):
brew deps [FORMULA] | xargs brew remove --ignore-dependencies
Remove package:
brew remove [FORMULA]
Reinstall missing libraries:
brew missing | cut -d: -f2 | sort | uniq | xargs brew install
Note that if you installed python with homebrew for your day-to-day use, and have only 1 package that depends on python...and then you remove its dependencies and the package itself, python will be removed too. The last line of code won't reinstall python because now there are no homebrew packages that depend on it.