Do not touch nodes that do not exist

Fixes #18289.