I am no Andy nor Michael but i can answer this
Imagine :
pcat_lvl_mapping = ValueMap
lvl1, lvl2, lvl3 = ValueMap
Each pcatList = string array (single)
Code :
Process.testPcat="pcat:22222";
Process.lvlList = getValueMapFields(Process.pcat_lvl_mapping);
for(i=0;i<lvlList.length;i++)
{
if(typeof Process.lvlOfPcat != "undefined" && Process.lvlOfPcat != "")
break;
Process.step.push(lvlList[i]);//For testing purposes only
for(j=0;j<Process.pcat_lvl_mapping[lvlList[i]].pcatList.length;j++)
{
Process.step.push(pcat_lvl_mapping[lvlList[i]].pcatList[j]);//For testing purposes only
if(Process.pcat_lvl_mapping[lvlList[i]].pcatList[j] == testPcat)
{
Process.lvlOfPcat=lvlList[i];
break;
}
}
}
So basically you use getValueMapFields to get a list of the valueMap contained inside a specific valueMap.
lvlList will contains :
Then you check every values in every pcatList by accessing each "lvlx" valueMap one by one with the first loop.
When it finds it, it wirtes the current valueMap being iterated then breaks.
The result is :
Sorry for the fuzzy explanation, it's easier to code than to explain