array2tree: check type compatibility and add docstring