You ask 3 times: Is the treasure in box 3?
Your last question is: Is the treasure in box 2?
.
If the guardian answer the first 3 questions the same all 3 times, he has lied all 3 times and he will answer truthfully the last question.
If he has said no 3 times, the treasure is in box 3.
If he has said yes 3 times, the treasure is in box 1 or 2. His answer to the last question (where he speaks the truth) will reveal which one.
.
Of the guardian answers the first three questions differently, he will have lied twice and spoken the truth once. That means his next answer will be a lie.
If he has said no 2 times, the treasure is in box 3.
If he has said yes 2 times, the treasure is in box 1 or 2. His answer to the last question (where he will lie) will reveal which one.