find all possible paths in a tree in python
问题 I am trying to create a list with all possible paths in a tree. I have following structure given (subset from DB): text = """ 1,Product1,INVOICE_FEE, 3,Product3,INVOICE_FEE, 7,Product7,DEFAULT, 2,Product2,DEFAULT,7 4,Product4,DEFAULT,7 5,Product5,DEFAULT,2 """ where the columns are: ID, product-name, invoice-type, reference-to-parent-ID. I would like to create list with all possible paths, like in the example: [[Product1],[Product3],[Product7,Product2,Product5],[Product7,Product4]] I do