code for updating post-order indexing