Avoid removing and re-adding node if it's already the first.

Make the small performance tweak mentioned in #53.