Within each chain, assign positions from top to bottom. Let pos[v] be the position of node in its chain, starting from . The topmost node in a chain has . As you DFS, maintain a counter chain_pos[c] for each chain . When you visit node in chain , set pos[v] = chain_pos[c] and increment chain_pos[c].
Now each node has two coordinates: which chain it is in via chain[v], and where in that chain via pos[v]. This lets you map tree nodes to segment tree indices.