I'd still be inclined to split that bit out - `extract_dates` could simply call the new function on anything that's not a list or a dict.