There is a tree structure of the plot with numerous branches, depending on the choice of the player. Each fork contains only two options.
This is arranged in the form of rows in the database table, where for each point its name is indicated, as well as the name of both points that a player can get from the current one.
We need a script to build an associative array, where each cell will contain two cells corresponding to possible transition points from this cell.
I understand how to recurse into the depths in order to build one branch of such a tree, I cannot understand how to return to the raw variants after that