I originally commented on this question with a response similar to user @phg, but then deleted it because I had skimmed through the post and wasn't sure I had got it right.
The aforementioned user then added an answer which was conceptual rather than a concrete implementation/code snippet. I added an answer, then deleted it when I realised it wasn't addressing OP's question. I then undeleted the same answer, added in the code snippet to resolve OP's issue, with comments on my changes to OP's logic, and also kept the code that was in my original post with an explanation of when that could be used. In doing so, I have already stated that my answer is basically a concrete implementation of the concepts discussed by @phg.
In this scenario, would it be considered acceptable to keep my answer, since I believe it is adding value rather than merely repeating another answer?