somewhat working subarray and tree classes