I think you're being a little too harsh on ol' Robert E., Set. It was quite common at the time to feel that one's first obligation was to his State. The whole concept of the United States as a Federation, somehow superior to the individual State, had never been a comfortable one with people in either section of the country. (New Hampshire was, historically, the first state to threaten secession; at the time this seemed a perfectly reasonable choice.)
Lee stayed loyal to the Union long after the Carolinas and Alabama and Mississippi etc,. had already announced they were no longer members of the United States In fact, he ran into some hostility in Texas, where he was stationed at the time, when he refused to doff his Federal uniform and peacefully turn his post over to the Texas rbels. (Incidentally, he was a Colonel or Lt. Col. in the US Army at the time [too lazy to look it up now] and throughout his service to the Confederacy never wore anything but a Colonel's insignia o his uniform. That had been his Federal rank. It's a partial explanation, at least, of why he referred to other Federal officers by their peacetime ranks.)
He was offered command of the Army of the Potomac by President Lincoln long before McClellan was even considered for the post. Eery indication is that he was seriously considering accepting the offer when his native state of Virginia finally seceded. Lee felt he had no choice, no options. He was, in his own mind, first of all a Virginian.
There was nothing unusual about this sort of sentiment. Before the War, it was common to use the expression "the United States are ...[etc.]" It wasn't til after the War that that expression changed to "the United States is
..." Back in the 1850s and 1860s very few people thought of the USA as one country, singular. Don't frget that prior to the adoption of the Constitution, the country had been run under the Articles of Confederation.
I think it is a measure of 20th Century sentiment -- foreign to the thought of the 19th Century -- to brand Robert E. Lee a "traitor."