Implemenetation of heap tree