Replace identical nested divs within different outer div from javascript

I have this problem which I am trying to solve after I cloned a div multiple times using javascript. I want to replace the inner div with an empty div having a particular id for each. Assuming I have:

<div id="original">
    //some code here
        <div id="problem">
            //some code here
        </div>
    </div>

<div id="location">
//some code here
    <div id="problem">
        //some code here
    </div>
</div>

<div id="rep">
//some code here
    <div id="problem">
        //some code here
    </div>
</div>

I need to be able to get the div with id problem in the div location and replace it with something else and same to the div within the div repository.