DRY up dynamic_cast of ValuePattern