OSM is a spatial dataset and the dependencies/hierarchies you are looking for are expressed by the objects being spatially "inside" each other, so a sate state boundary would be inside the countries boundary, a municipalities boundary inside the state boundary and so on.
That's the theory.
In real life we don't have boundaries for all such entities and in the case of non-administrative-entity places we currently don't even have an accepted modelling for areas (they will typically be represented by nodes in the absence of boundaries). And just how complete the existing data is will depend very much on what countries and regions you are looking at.
The other bad news is that in the OSM data model the geometry information is carried by the Node objects and "raw" OSM data doesn't contain pre-built geometries for polygons and multi-polygons that would represent the boundaries.
The simplest ways to get the boundary geometries and to be able to query the data spatially is to either use an [OverPass API/OverPass Turbo](https://wiki.openstreetmap.org/wiki/Overpass_turbo) server or run your own [osm2pgsql](https://wiki.openstreetmap.org/wiki/Osm2pgsql) database. There are a number of libraries that will parse OSM data for you and create geometries if you want to do this on foot, most notably [Osmium](http://osmcode.org/).