Fix toArrayRecursive method