The Prohibition
The Federal Election Campaign Act (FECA) prohibits any foreign national from contributing, donating or spending funds in connection with any federal, state, or local election in the United States, either directly or indirectly. It is also unlawful to help foreign nationals violate that ban or to solicit, receive or accept contributions or donations from them. Persons who knowingly and willfully engage in these activities may be subject to fines and/or imprisonment.
Foreign Nationals Brochure
18 USC § 2381 - Treason
Whoever, owing allegiance to the United States, levies war against them or adheres to their enemies, giving them aid and comfort within the United States or elsewhere, is guilty of treason and shall suffer death, or shall be imprisoned not less than five years and fined under this title but not less than $10,000; and shall be incapable of holding any office under the United States.
18 USC § 2386 - Registration of certain organizations
An organization is “subject to foreign control” if:
(a)it solicits or accepts financial contributions, loans, or support of any kind, directly or indirectly, from, or is affiliated directly or indirectly with, a foreign government or a political subdivision thereof, or an agent, agency, or instrumentality of a foreign government or political subdivision thereof, or a political party in a foreign country, or an international political organization; or
18 USC § 2386 - Registration of certain organizations | LII / Legal Information Institute
While it's true that any candidate that accepts campaign money from foreign sources is breaking Federal law,
it is a bit of a leap to suggest that those who vote for a candidate that does not meet the definition of having committed treason are themselves doing the same.