Format a tree from lines