Then shall the righteous answer him, saying, Lord, when did we see you hungred, and fed you? or thirsty, and gave you drink?
When did we see you a stranger, and took you in? or naked, and clothed you?
Or when saw we you sick, or in prison, and came unto you?
And the King shall answer and say unto them, Verily I say unto you, Inasmuch as ye have done it unto one of the least of these my brethren, ye have done it unto me. Mt 25:24-40
-------
One of the most significant parts of this example is that the righteous didn't even realize they were helping God when they helped their neighbor. They asked, "when did we help you"? In other words, they were not performing these behaviors as a religious observance. They were just showing love, which is what God wants us to do, so he saved them.
In the story of the Good Samaritan, there is no mention of the stranger having correct theology or affiliation with the correct religious view. Instead, he is saved solely based on his willingness to show love for his neighbor.
When Jesus said, "I am the way, the truth and the life; no one comes to the father but by me" he was not talking about correct religious affiliation. He was talking about his teachings, which are the values of the Kingdom of Heaven. The "way" of the kingdom of Heaven is illustrated in the teachings of Jesus, which is why he was so insistent that we obey him.
As in the story of the Good Samaritan, any person who does not know of the name of Jesus, but still loves his neighbor will be following the way of Jesus even if he does not consciously recognize it as the way of Jesus.