1. A method of automatically partitioning a visual display of a tree comprising data elements into a plurality of labeled parts, said method comprising: (i) accessing information about the data elements, the data elements of the visual display of the tree including at least visually displayed containers and visually displayed connectors connecting the visually displayed containers; (ii) forming an undirected graphical model of the data elements using the accessed information, wherein the undirected graphical model comprises a plurality of nodes each associated with a portion of the data elements and a plurality of edges connecting the nodes, wherein each node and edge is associated with a potential function, each potential function having a weight that is pre-computed during a training state the weight determined according to whether the nodes at the ends of the edge belong to a same part, to different parts with a same label, or to different parts with different labels; and (iii) using the undirected graphical model to simultaneously partition the data elements into the plurality of parts and associate the data elements with labels, the labels including at least a container label and a connector label, wherein The simultaneously partitioning and labeling includes simultaneously determining an optimum label and a partition associated with each node based at least on part on a collection of previously labeled and partitioned graphical models and the weights obtained during the training state are used and a maximum a posteriori solution is sought in order to find the optimum labeling and its probability; Each part of the plurality of parts is represented by a contiguous region in the undirected graphical model with all nodes in the contiguous region having a same label, the label being different from labels of other nodes belonging to others parts of the plurality of parts, at least one of the other nodes being contiguous with at least one of the nodes in the contiguous region, at least one of the parts includes two or more of the plurality of nodes, each node belongs to only one part, and the partitioning includes using message passing with a modified sum product algorithm, the modified sum product algorithm computing sums over a subset of all possible partitions, wherein an edge potential is associated with each edge, a given edge potential being a function of at least interaction features associated with that edge weighted with a value according to whether nodes at the ends of the edge belong to the same part.