A religious practice cannot extend to the exclusion of certain castes, Justice B. V. Nagarathna said