generalize tomato miner, allow both minimal and expanded bfs