This shows how our morality is based on, shall we say, concentric circles. We take care of our children and parents before other relatives, relatives before acquaintances, acquaintances before strangers, strangers of our own nationality before those of other nationalities, human beings before nature in general, etc.
Of course these circles are general, not absolute: it is OK to give up an afternoon with one's child to do some significant good for society at large. They might change: if a relative did you a serious wrong, he might forfeit any claim to be considered before strangers. They sometimes conflict and give no easy answers: do we save two strangers or one relative? They depend on the type of help: it is OK to help one's relatives to a certain degree, but cronyism is wrong. And so on.
So there is no easy formula to consider all possibilities, and there are cases of genuine conflict.