sub parse { my @stack = @_; while (@stack) { my $node = pop @stack; print $node->{data}; push @stack, @{$node->{children}}; } }