Help with Formula

I need Project Health to be based on the count of children's health, but if there is a similar number between the two statuses, select the most critical one. I'm using this formula, and it's given me a red color when the majority are yellow.

=IF(COUNTIF(PARENT([Health]@row), "Red") > COUNTIF(PARENT([Health]@row), "Yellow") + COUNTIF(PARENT([Health]@row), "Green"), "Red", IF(COUNTIF(PARENT([Health]@row), "Yellow") > COUNTIF(PARENT([Health]@row), "Red") + COUNTIF(PARENT([Health]@row), "Green"), "Yellow", IF(COUNTIF(PARENT([Health]@row), "Green") > COUNTIF(PARENT([Health]@row), "Red") + COUNTIF(PARENT([Health]@row), "Yellow"), "Green", IF(COUNTIF(PARENT([Health]@row), "Yellow") = COUNTIF(PARENT([Health]@row), "Red"), "Red", IF(COUNTIF(PARENT([Health]@row), "Red") = COUNTIF(PARENT([Health]@row), "Green"), "Yellow", IF(COUNTIF(PARENT([Health]@row), "Yellow") = COUNTIF(PARENT([Health]@row), "Green"), "Yellow", ""))))))

Answers