Focus on this block of code:

if (next.sibling!=null)
next=next.sibling;
next.sibling=member;
if...