The last (purple colored) part of the query identifies all reaction nodes that are on the shortest paths for the target molecule given the search depth, then it expands the reaction nodes to the immediate neighbors, hence ensuring all the reactants, reagents, products are always included for all reactions. This is needed due to sometimes substances being left out because the shortest path algorithm will choose only one path through the network given the same start and end nodes, and multiple choices of paths of equal length between them.