Since you keep a reference to last_node, you don't need to step through the list here. It costs you O(n) steps instead of jumping straight to the end for an O(1) insert.