1. A method for encoding a tree, the method comprising: receiving an input tree comprising a plurality of nodes, organized in a parent-child hierarchy, a parent node comprising one or more child nodes; assigning a node ID to each of the plurality of nodes of the input tree; generating a representation between each parent node and the each of the child node associated with the parent node; computing a tree code for from prime numbers in the natural sequence of numbers, and the assigned node IDs to each of the parent node and child nodes; and storing the tree code representative of the input tree.