implement Node#replace