The key here is to make a print function that you'll be able to call recursively. I'd suggest something like this
function print_recursive($array, $depth = 0) {
//Code to print your stuff
//Calls the print function on the parent if it's an array
if(is_array($array['parent'])) {
print_recursive($array['parent'], $depth+1);
}
}
The depth parameter is 0 by default but we increment it by 1 when calling print_recursive on $array['parent']. This way, each time you get deeper in the array, it'll get incremented.