Make Node.contains function work correctly when given invalid arguments