I'm not good at English, so please take this into account when reading.
Since homebrew's deep dependencies cannot be retrieved with a simple script, I created an analysis tool.
Examine the formulas that all formulas depend on.
|-formula(B)
|
formula(A)-|-formela(C)
|
|-formula(D)
formula(A).deps = formula(B),formula(C),formula(D)
Examine all formulas that depend on that formula.
formula(X)-|
|
formula(Y)-|-formula(A)
|
formula(z)-|
formula(A).uses = formula(X),formula(Y),formula(Z)
Save to simple database.
The heart of this tool lies in the part that creates intermediate files.
Every time you start the tool, it updates the simple database in the background every hour.
retrieve all dependent formulas from the simple database,
Check whether the formula is dependent on other formulas than the one on which it is dependent,
Select only formulas that are dependent on dependent formulas.
Formulas that are multi-level dependent in the tree structure and are higher up are not selected.
Compare all formula dependencies and extract unnecessary formulas.
Linux has special dependencies and takes time.
Linux's efl dependencies are a tree structure of over 10 million lines.
This is one of the functions of the tool, but since the source is long, I will paste a link.
command
bl -dd <formula> # dry-run
bl -ddd <formula> # [y/n]
For example, if you want to remove the efl dependency but leave the ffmpeg dependency
bl -ddd efl ffmpeg
https://github.com/konnano/brew_list
brew autoremove
is what you're looking for: