typeSafeUnlist function

Unlist a list into a vector in a type-safe way where possible.