Comparing different references (Firebase)

I am trying to develop a question-answer app. Firebase database looks like this:

-users
    -userId
        -answers
            -questionId : answer
            -questionId : answer

-questions
    -questionId
    -questionId
    -questionId
    -questionId

If a user answers a question, that question is stored under answers section according to userId. My problem is to find an unanswered question by the user and show it on the activity. To do this, first, I pick a question from questions list then check if it exists in answers list. This is the method:

public void showUnansweredQuestion()
{
    questionsRef.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for(DataSnapshot question: dataSnapshot.getChildren())
            {
                final String questionId = question.getKey().toString();

                usersRef.child(user.getUid())
                        .child("answers")
                        .addListenerForSingleValueEvent(new ValueEventListener() {

                            @Override
                            public void onDataChange(DataSnapshot dataSnapshot) {
                                if(!dataSnapshot.hasChild(questionId))
                                {
                                    updateUI(questionId);
                                }
                            }

                            @Override
                            public void onCancelled(DatabaseError databaseError) {}
                        });
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {}
    });
}

However, this methos always shows the last unanswered question while I want to see the first one. Problem is probably for loop, I cannot write break in if or cannot define a flag because of the inner class. Do you have any suggestion?