Refactor isEqualNode()