Lucy Letby, 32, is said to have deliberately harmed the prematurely born youngster on two separate occasions on successive night shifts at the Countess of Chester Hospital's neonatal unit.
Child H survived the alleged attempted murders and went to make a full recovery when she was transferred to a different hospital and was later discharged in good health.
She needed resuscitating in the early hours of September 26 and September 27, 2015, and was rushed to Wirral's Arrowe Park Hospital as no clear cause for the collapses could be identified.
Child H had earlier experienced a series of falls in blood oxygen levels and heart rate, with a number of pneumothoraxes (collapsed lung) identified. This followed a diagnosis of respiratory distress syndrome, a common complication with premature babies, Manchester Crown Court was told.
Prosecution expert Dr Sandie Bohin, a consultant paediatrician, agreed that surfactant, a medication to reduce stiffness of lungs, was given late to Child H.
She was already on ventilation support so the stiffness of the lungs would make it more likely to develop a pneumothorax, she said.
Medics treating the life-threatening condition went on to insert a needle to remove fluid or air from between the chest wall and the lung. However, the needle was left in place as a chest drain - a tube used to drain air - was later put in.
Ben Myers KC, defending, asked Dr Bohin: "That (the needle) should be removed as soon as possible. It has a sharp tip that can tear delicate tissue as the lung expands, doesn't it?"
"Yes," said Dr Bohin.
Mr Myers said: "That's suboptimal practice, isn't it?"
Dr Bohin replied: "Yes, because it is hazardous."
Child H needed a total of three chest drains on her left side as the lung problems continued, the court heard.
The defence say the second drain was put in the wrong place.
Dr Bohin agreed it was in a "suboptimal position" but said it was a life-saving measure.
She agreed it went "further in" than would be optimal and X-rays later showed it moved around.
Mr Myers referred to a clinical note from a doctor at the Countess of Chester who stated a "possible cause for cardiac arrest is if a chest drain is too close to the heart and touching the pericardium".
Mr Myers asked: "The tip of the drain could have contributed to the collapse, couldn't it?"
Dr Bohin said: "I have discounted it. I don't think the positioning of the drain has caused a cardiac arrest."
She agreed that needing to insert three chest drains in one patient was "unusual" but added: "What you have to do is treat the clinical situation in front of you."
Mr Myers said: "There had been some suboptimal care of (Child H) in the days leading up to this, hadn't there?"
"Yes," said Dr Bohin.
The court heard Dr Bohin and fellow prosecution expert Dr Dewi Evans had not identified any cause to account for the two sudden cardiac arrests.
Dr Evans told the court the chest drains were "life-savers".
He disagreed with Mr Myers's suggestion that it was "entirely possible" all the medical interventions Child H underwent could have contributed to the collapses.
Dr Evans said: "I don't think that was the case. I think the care she got was pretty good."
Letby, originally from Hereford, denies the murders of seven babies and the attempted murders of 10 others between June 2015 and June 2016.
The trial continues.