% add to list && whostnext
function [leavesorder,nodesorder,c,d,z]=additnow(leavesorder,nodesorder,addtolistl1,addtolistn1,addtolistl2,addtolistn2,c,d,y,e,r,n)


if addtolistl1~=0
    leavesorder(c)=addtolistl1;
    c=c+1;
end
if addtolistn1~=0
    nodesorder(d)=addtolistn1;
    d=d+1;
end
if addtolistl2~=0
    leavesorder(c)=addtolistl2;
    c=c+1;
end
if addtolistn2~=0
    nodesorder(d)=addtolistn2;
    d=d+1;
end

z=y;
if e~=0 || r~=0
    
if e~=0 && e>n && e<y && (e<r || r==0)
    z=e;
end
if r~=0 && r>n && r<y && (r<e || e==0)
    z=r;
end


end
end