Change null node check from assert() to if-return