Make flattenObject only flatten plain object preserving objects like Date