fix #9327 - tagging presets: fix handling of nested <reference>s, refactor railway presets
<reference>