I want to traverse the object graph starting at a specific root object and find which path, starting from it, leads to an object with a property that has a given value. This is my code so far:
function findPropertyValue(obj, value) {
if (typeof obj.seenBefore === "undefined") {
// treat for object graph circularity
obj.seenBefore = true;
for (var key in obj) {
if (obj[key] == value) {
return key;
} else {
if (obj[key]) {
var foundIt = findInput(obj[key], value);
if (foundIt) {
return key + '.' + foundIt;
}
}
}
}
}
return false;
};
The problem with it is that it very quickly hits the call stack size limit on Chrome and is unable to continue with the search. Is there another way to do this OR to increase the stack size limit only for debugging purposes?