#20: Added more advanced pattern matching to _collect_paths().