It looks like I will have to find some way to differentiate between non-terminal and terminal nodes for this process. This will take some thought