1. A method for encoding a tree, via a processor executing code, the method comprising: receiving, via a processor, an input tree comprising a plurality of nodes, organized in a parent-child hierarchy, a parent node coupled to one or more child nodes; assigning, via the processor, a node ID to each of the plurality of nodes of the input tree; generating, via the processor, a representation between each parent node and the each of the child node associated with the parent node; computing, via the processor, a tree code from prime numbers in the natural sequence of numbers, and the assigned node IDs to each of the parent node and child nodes, wherein the tree code is computed according to the formula: 
 Tree Code= p n1 m1 *p n2 +*. .. *p nk mk where, p ni is the ni th prime number in the natural sequence of numbers, ni is the node ID of the i th parent node in the parent-child table, and mi is the number of children of the i th parent node in the parent-child table; and storing the tree code representative of the input tree.