this function inserts the new node newnode right before the node refnode the return value is the inserted node if you plan to do further modifications on the appended child you must use the returned node 