Python: From a list containing tree info, generare a tree in dict format