Remove nth node from end function