subroutine dump_tree_table(tree)
use, intrinsic :: iso_fortran_env, stderr => error_unit
implicit none
class(tree_node_t), intent(in) :: tree(:)
integer :: i, k
write(stderr, '(1x, a)') ' own index| operation| parent| left| right| registered| segments'
do i = TREE_NODE_BASE, ubound(tree, dim=1)
if (tree(i)%is_registered) then
write(stderr, '(5i12, a, 10x, 1l, 3x)', advance='no') tree(i)%own_i, &
tree(i)%op, tree(i)%parent_i, tree(i)%left_i, tree(i)%right_i, ' ', &
tree(i)%is_registered
if (allocated(tree(i)%c)) then
do k = 1, ubound(tree(i)%c, dim=1)
if (k /= 1) write(stderr, '(a)', advance='no') ', '
write(stderr, '(a)', advance='no') tree(i)%c(k)%print()
end do
write(stderr, *) ""
else
write(stderr, *) " "
end if
end if
end do
end subroutine dump_tree_table