public Automata buildDFA() {
        if (states.length > maxStateOfNFA) {
            return null;
        }
        optimaze();
        Automata a = createTemplateForDFA();
        int maxMask = (1 << states.length);

        Queue<Integer> queue = new LinkedList<>();
        boolean was[] = new boolean[maxMask];
        for (int i = 0; i < maxMask; i++) {
            was[i] = false;
        }

        queue.add(pow[state0.getNumber()]);
        was[pow[state0.getNumber()]] = true;
        while (!queue.isEmpty()) {
            int mask = queue.poll();
            State curState = a.states[mask];

            for (Character ch : alphavet) {
                if (ch == 'e') {
                    continue;
                }
                int nextMask = getNextStatesOfMaskByCharacter(mask, ch);
                if (nextMask != 0) {
                    if (!was[nextMask]) {
                        was[nextMask] = true;
                        queue.add(nextMask);
                    }
                    curState.addNextState(ch, a.states[nextMask]);
                }
            }

        }
        a.state0 = a.states[pow[state0.getNumber()]];
        a.optimaze();
        return a;
    }