Define Tree class to handle hierachical data