protected function genHierarchy($xml){
        if (!$xml){
            return false;
        }
        $a = array();
        $a['ProductCategoryId'] = (string)$xml->ProductCategoryId;
        $a['ProductCategoryName'] = (string)$xml->ProductCategoryName;
        if ($xml->Parent){
            $a['Parent'] = $this->genHierarchy($xml->Parent);
        }
        return $a;
    }
protected function genHierarchy($xml){
        if (!$xml){
            return false;
        }
        $a = array();
        $a['ProductCategoryId'] = (string)$xml->ProductCategoryId;
        $a['ProductCategoryName'] = (string)$xml->ProductCategoryName;
        if ($xml->Parent){
            $a['Parent'] = $this->genHierarchy($xml->Parent);
        }
        return $a;
    }
protected function genHierarchy ( $ xml ) { if ( ! $ xml ) { return false ; } $ a = array ( ) ; $ a [ 'ProductCategoryId' ] = ( string ) $ xml -> ProductCategoryId ; $ a [ 'ProductCategoryName' ] = ( string ) $ xml -> ProductCategoryName ; if ( $ xml -> Parent ) { $ a [ 'Parent' ] = $ this -> genHierarchy ( $ xml -> Parent ) ; } return $ a ; }
Recursively builds the hierarchy array.

The returned array will have the fields <b>ProductCategoryId</b> and
<b>ProductCategoryName</b>, as well as maybe a <b>Parent</b> field with the same
structure as the array containing it.
@param SimpleXMLElement $xml <p>The XML data from Amazon.</p>
@return array Recursive, multi-dimensional array
Recursively builds the hierarchy array .