I suggest moving line 9 before line 8, and then removing line 23 and see if that gives you your intended results.
A simpler way (I believe you're looking for duplicate values?) is to use a basic for loop (if you have C++11 features (auto), it's even easier) inside of another for loop.
1 2 3 4 5 6 7 8
// First iterator
for (list<int>::iterator i = L.begin(); i != L.end(); i ++)
// Second iterator to compare against
for (list<int>::iterator j = i + 1; j != L.end(); j ++)
// Check to see if the values are equal
if (*i == *j)
// If they are, erase it
i = L.erase(i);
I didn't have all of your code, and don't feel like typing it all up just to test it, but that should work. You can add a break in there if you know there is only going to be one duplicate.