Returns an array of integer indexes with null termination.
Returns NULL if no children, or invalid index, or not enough memory when allocating the array.