@grishka @Gargron @drq postgresql has the ltree extension for something like this.