title: Loop through all combinations of a multiset elements
body: <p>I need to find the best path in a tree, the tree is all possible combinations of elements of a <code>multiset</code>.
  For example for this <code>multiset</code> : A - B - C, the tree would be composed of all the 6 possible combinations :
  A - B - C  |
  A - C - B  |
  B - A - C  |
  B - C - A  |
  C - A - B  |
  C - B - A  </p>
  
  <p><img src="https://i.stack.imgur.com/NOtaD.png" alt="enter image description here"></p>
  
  <p>I want to loop trough this tree using the multiset only,</p>
  
  <p>Something like this :</p>
  
  <pre><code>// I think this must be initialized, but that is not a problem
  Path bestPath;
  
  for (mySet::iterator i(aSet.begin()), e(
                      aSet.end()); i != e; ++i) {  
           Path path = someRecursiveFunction(*i);
           if(criteria(bestPath,path))
                bestPath = path;
           return bestPath;
  }
  </code></pre>
  
  <p>and <code>someRecursiveFunction</code> must probably be the same, but looping on the rest of the values, I dont want to create a multiset in each node and put the rest on it, since the number of nodes is factorial the size of the multiset,
  I can't find a good way to do this ... </p>