Best in Bags already does what you want I think.
Let’s say Windwalker is set as your top-priority spec, and Mistweaver as your second spec.
First it will optimizer Windwalker with no restrictions. The best possible gear with the best gems and enchants will be chosen. Let’s say it chooses chest piece A with a crit gem.
Next, it will optimize Mistweaver with only one restriction, best described by example: it can’t change the crit gem in chest piece A. So it will pick the best possible gear and gems and enchants for Mistweaver, as long as it doesn’t change a gem/enchant “reserved” for Windwalker.
In many cases, uses the same chest piece as your Windwalker set but with the “wrong” gem for Mistweaver is better than any alternative chest piece you might have.
Does that describe how you want it to work?