Lets compare this to the days of slavery before the civil war. Lets say a female slave decides to try to make her escape to one of the free states. She brings her child with her. About half way through her journey, she dies but her child makes it the rest of the way to freedom.
Then the father, still residing in the slave state as a slave, of the child demands that the child is returned to his custody where the child will be a slave too. Do you return the child to the father.
In your situation, what was the law? The US had a treaty with Cuba that recognized parental rights.