Collect extracted value to form a namespace list

I extract some information out of xsd using DFS. Now I want to collect those information and form a namespace list. For instance, the original tree may look like

             1
    2        3            4
5     6       7       8    9    10     

1 contains [2, 3, 4]
2 contains [5, 6]
3 contains 7
4 contains [8, 9 10]

Extracted sequence looks like

1 
+  2 
   + -> 5 
   + -> 6
+  3
   + -> 7 
+  4 
   + -> 8
   + -> 9
   + -> 10   

Now I want to collect these sequences to form a list with the format like

1.2.5
1.2.6
1.3.7
1.4.8
1.4.9
1.4.10

What I can think of is to use TrieMap or trie data structure to insert and then flatten to create such list. But I don’t find a good example that tell how to use that. The only thing so far I find is

https://www.programcreek.com/scala/scala.collection.concurrent.TrieMap

But it’s not highly related. And it’s still not clear how can I apply that to my problem.

Is this the right direction to go? Any advises on this? Much appreciated any commentaries.

Thanks!

Eventually this is done using DFS traversing each node, and a collector collects prefix when each node is visited.

val collector = Map()

def dfs(graph) {
    val child = ..get child()
    // operation that adds node to collector 
    dfs(child)

}

dfs(<xsd graph>)