Handle NULL nodes in `node_matches`