Returns an array of integer indexes, with null termination.
Returns NULL if children exist, or if not enough memory exists when allocating the array. The array is a copy that should be freed when done.