I'm having the recursion loop of which should return value if it's found at some nested level in ArrayCollection. Once return value is found and returned by function but in next iteration return value becomes back to null. What I'm missing or doing wrong?
// calling function
...
foundedItem = this.recursiveFindFunction(valueList);
...
private function recursiveFindFunction(items:ArrayCollection):Object
{
var retVal:Object;
for (var i:int = 0; i < items.length; i++)
{
var value:Object = items.getItemAt(i);
if (value.name == this.attribute.value.directValue as String)
{
retVal = value;
break;
}
if (value.hasOwnProperty("children"))
{
this.recursiveFindFunction(value.children);
}
}
return retVal;
}