populating next right pointers to a tree with constant space and do it in one pass