I wanted to open an issue to understand why `bnb_search` as [implemented](https://github.com/bitcoin/bitcoin/pull/10637) @achow101 does not terminate once an optimal search is found.  This behavior is evident I believe when inspecting the [test](https://github.com/bitcoin/bitcoin/blob/master/src/wallet/test/coinselector_tests.cpp#L178) which sets the target to `5` and uses the utxo pool `4,3,2,1`.  since combinations of `4` are evaluated first, the `bnb_search` finds an optimal solution of `4,1`.  However, instead of terminating when the `best_waste = 0` (no better solution can be found), the search continues and instead finds another solution `2,3` which also has a `best_waste = 0`.  Why not terminate once an optimal solution is found instead of continuing to search?
std::default_random_engine generator;
    std::exponential_distribution<double> distribution (100);
    FastRandomContext rand;
    
    for (int i = 0; i < 100; ++i)
    {
        empty_wallet();
        
        for (int j = 0; j < 1000; ++j)
        {
            add_coin((CAmount)(distribution(generator)*10000000));
        }
        
        CFeeRate rate(rand.randrange(300) + 100);
        
        CAmount target = rand.randrange(balance - 1000) + 1000;
        
        CoinSelectionParams coin_selection_params_knapsack(false, 34, 148, CFeeRate(0), 0);
        CoinSelectionParams coin_selection_params_bnb(true, 34, 148, CFeeRate(0), 0);
        CoinSet out_set;
        CAmount out_value = 0;
        bool bnb_used = false;
        BOOST_CHECK(testWallet.SelectCoinsMinConf(target, filter_standard, GroupCoins(vCoins), out_set, out_value, coin_selection_params_bnb, bnb_used) ||
                    testWallet.SelectCoinsMinConf(target, filter_standard, GroupCoins(vCoins), out_set, out_value, coin_selection_params_knapsack, bnb_used));
        BOOST_CHECK_GE(out_value, target);
    }
}
BOOST_AUTO_TEST_SUITE_END()