To determine which variant contains a sentence with homogeneous sentence terms, we should look for sentences that include multiple items of the same grammatical type that are linked by a conjunction (e.g., "and," "or," "but").
The boys wandered around the garden until evening, but they had to leave with almost nothing. - "but" connects two clauses, but they do not share uniform grammatical elements.
If I finish earlier, then we will go to the cinema. - This is a conditional sentence with two clauses but does not contain homogeneous terms.
Waking up in the early morning, he went out for a run. - This sentence is a single clause and does not have homogeneous terms.
Roofs and distant forest clearings were covered with snow overnight, but soon melted. - The part "Roofs and distant forest clearings" contains homogeneous terms (both are nouns) connected by "and."
Thus, the sentence that contains homogeneous sentence terms is 4).
