Mazepa was a traitor to Russia but not to Ukraine. Just like George Washington was a traitor to Britain, but not to America.
Washington revolted against Britain, while Mazepa joined a foreign army. That's like if Washington had joined the French during the contemporary colonial wars.