Did you replace the entire isRelated function with the code you posted, or just a section of it?
Nevermind, I think I see. You just wrapped the related=related.parentNode line in a try block.
(*) Discounts available for the above products!