Add a missing check for unknown nodes

Also combines some `if`s.