Request for code to filter tracks with multiple connections

I am looking for code that can help me visualize all tracks (highway=track) in a specific area that have additional connections to other roads or paths at their endpoints or inside the segment. This would be useful for identifying potential routes for hiking or biking that utilize existing infrastructure.

Example:

Consider a track segment that connects two different roads. The code should identify this segment and include it in the results.

Additional considerations:

  • The solution should be applicable to any area and not limited to a specific region.
  • The code should be efficient and avoid unnecessary data processing.
  • The output should be easy to interpret and visualize, ideally in a format compatible with mapping tools.

Request:

Could someone provide Overpass Turbo code that can achieve the desired functionality? Any assistance would be greatly appreciated.

Additional information:

  • I have tried using the following code, but it does not return the desired results:
[out:json][timeout:25];
way["highway"="track"]({{bbox}});
out geom;
  • I am using Overpass Turbo to run the queries.

Thank you for your time and consideration.

I’ll reply here too, maybe others can help us,
a possible solution:

[out:json][timeout:30][bbox:{{bbox}}];

way["highway"]["highway"!~"footway|path"]->.streets;
node(way_link.streets:1)->.no_exit;
way(bn.no_exit)["highway"="track"]->.tracks_no_exit;
//.tracks_no_exit out geom; //debug

way["highway"="track"]->.all_tracks;
(.all_tracks; - .tracks_no_exit;)->.tracks_with_exit;
.tracks_with_exit out geom;

link for the query : overpass-turbo
some suggestions ?