Greatly simplify the implementation of brew-leaves
Make brew-leaves respect optional deps
Move brew-leaves into core

Closes #24371.
brew-pull: run `git am --abort` on failure.