working version to parse dot to a tree structure