function recursiveChild(p) {
var children=p;
for (var i = 0; i < children.length-1; i++) {
var counter=0;
children[i].replace(regvm,vr); //do some changes on text
//this counter is so that i can break the loop
if (children[i].hasChildNodes==False){
counter++;
// console.log ("first if reached");
//this should break recursion
if (counter== children.length-1){
// console.log ("second if reached");
break;}
}
p= p + p[i].children;
}
return recursiveChild(p);
}