Plz help me analyze this sentence
"The happiness which he attributes to religion he could have obtained from becoming a crossing-sweeper, provided he were compelled to remain one. "
I couldn’t understand the latter part of the sentence. Please paraphrase it and analyze its grammatical construction for me. Thanks!