My master thesis is going in the wrong direction
As a researcher, you should expect to fail.

In general, you will frequently finding yourself coming up with ideas that don't pan out, results that suggest that what you did previously was wrong, or that a particular problem can't be solved yet (you need to do time-consuming step X before you can tackle interesting problem Y). Encountering these situations doesn't mean that what you've done is wrong, it means that you're doing research. (If everything you do is always successful, I'd argue you're doing development, as opposed to research.)

Success as a research comes from learning to cope with and overcome adversity. So I'd suggest that you use this as a learning experience. Rather than be depressed about it, try to work around your problems. It will be a valuable tool that will stay with you for the rest of your career.

Now, with respect to handle the master's thesis itself, this is something that you need to discuss with a number of people: your Betreuer (the person in charge of the thesis), as well as the head of the institute plus the person in charge of supervising students in your department. This is particularly important because your Betreuer is not normally allowed to grade your thesis, unless the Betreuer is a professor. Therefore, the people doing the grading may not be aware of the issues you had in the process. However, I would advise you to frame your questions in a positive way: that is, ask 


  What can I do to make sure I end up with a successful thesis?


rather than 


  How do I get myself out of this problem?


The former is much more likely to result in a satisfactory resolution than the latter.