Relational database management systems based on SQL are only conditionally suitable for hierarchical or recursive queries. In this case other systems like ArangoDB are better (there was a great talk about this at the GOTO 2016). But you can also create recursive queries in SQL using Common Table Expressions and thus query e.g. classic parent/child tables for all ancestors and descendants.
In PostgreSQL, this would look like this:
If you now want to get all children of a certain item_id, use the common table expressions:
Also the query of the parents is no problem: