Thanks again, johnny_d. I think I get generally how you constructed the arrays and then used embedded foreach statements to render the data in a way that reflects the parent/child relationships. One of things I don't understand is the array syntax in which it appears that there are 2 values for the key in the array, eg:
$step[$d['pid']][$d['sid']] = $d['step'];
What does it mean when 2 values ($d and $d)are defined side-by-side on the 'key' side of the equation?