The test.assert*
functions are there for asserting a certain condition. Remove it because you want to branch the execution. Otherwise is your code correct.
test.assertExists("#myID");
// this function will not be executed if #myID wasn't there
var id = 'myID';
if(this.evaluate(function (pageCtxId) {return document.getElementById(pageCtxId).checked;}, id))
{
this.click('#'+id);
}