Make tree encoding accept Array format too