I am trying to make a recursion call of this.isParentEmpty() inside this method and I need to stop this recursion once all the items are visited . Maybe using a counter.. Here for example I have items.length as 3 then the recursion should only happen till the time the length is met and break after that in order to avoid infinite loop or circular dependencies.. What could be the stopping condition for this??
isParentEmpty(item, items) {
const parentSystemRecordId = R.path(['parent', 'id'], item);
if(!parentSystemRecordId || !item.isDependentList) {
return false;
}
const parentItem =
items.find(({ _id }) => Number(_id) === parentSystemRecordId);
if(this.isParentEmpty(parentItem, items)) {
return true;
}
return parentItem && !R.path(['value', 'id'], parentItem);
}