After a severe collapse of her left lung in March, Castillo needed regular hospital visits to clear her airways and was unable to take care of her children.
Doctors initially thought the only solution was to remove the entire left lung. But Dr Paolo Macchiarini, the head of thoracic surgery at Barcelona's hospital clinic, proposed a windpipe transplant instead.
Once doctors had a donor windpipe, scientists at Italy's University of Padua stripped off all its cells, leaving only a tube of connective tissue.
Meanwhile, doctors at the University of Bristol in the UK took a sample of Castillo's bone marrow from her hip.
They used the bone marrow's stem cells to create millions of cartilage and tissue cells to cover and line the windpipe.
Experts at the University of Milan then used a device to put the new cartilage and tissue onto the windpipe.
The new windpipe was transplanted into Castillo in June.
So far, Castillo has shown no signs of rejection and is not taking any immune-suppressing drugs, which can cause side effects like high blood pressure, kidney failure and cancer.
Castillo's doctors say she is now able to take care of her children, and can walk reasonable distances without becoming out of breath.
Macchiarini describes the state of Castillo as "excellent" and says that if she maintains her current health he will be the "happiest doctor in the world".
People who might benefit from this kind of treatment include children born with defective airways, people with scars or tumours in their windpipes, and those with collapsed windpipes.
It is also thought possible that the technique could be adapted to other organs such as the the bowel, bladder, or reproductive tract.