I believe it's not the same. The code snippet (i attached above) is working fine when directly executing with the node.js. it's only throwing the error when code is being executed by node-red function.
This is likely due to the way the function node runs it's code inside the VM modules - that can have odd side effects in code that tries to do certain types of comparison between an object created inside the VM and one created outside.
If that is the case, there isn't a short term solution I can give you - it's a consequence of how the node works.
I was heading to the same conclusion & now you say it, I believe that is the issue.
@vinaysudani I tried it in nodejs and a function node and see the same issue you do.
As a workaround, I changed the __is_object function to return value && typeof value === "object" && value.constructor && value.constructor.name === "Object" & it works in the function node vm.
Maybe you could raise an issue against the repo stating it doesn't work as expected in a nodejs vm?