Document the reason for the casts in containsNode and simplify to assume the standardized version.