Why Is My Kitten Throwing Up Foam?

My kitten has been throwing up foam for two days in a row. It is very dark in color and looks like it’s coming out of her mouth. I have tried giving her Pedialyte, since she doesn’t seem to be dehydrated but if that wasn’t the cause, what could possibly cause this? She also takes heartworm meds every 6 months or so along with other medications for URI’s. Her last shot was three weeks ago by the vet so I don’t know why she recently started getting sick again. My brother said his cat threw up foam when he took him to the vet after being hit by a car.. Could that be at all related? Anyone have any ideas on what may have caused this?