public static synchronized void drawDTFractal(Graphics g, int startX, int startY, int maxBranches) throws Exception {
        if (g == null) {
            throw new Exception("Cannot draw on null graphics!");
        }
        g.setColor(Color.black);

        int currBranches = 0;
        int created = 0;
        Node baseNode = new Node(startX, startY);
        Node temp;
        ArrayList<Node> allNodes = new ArrayList<>();
        allNodes.add(baseNode);
        created++;

        while (currBranches < maxBranches) {
            g.clearRect(-10, -10, 3000, 3000);
            for (Node n : allNodes) {
                n.draw(g);
                temp = n.createBranch();
                if (temp != null) {
                    allNodes.add(temp);
                    created++;
                }
            }

            try {
                Thread.sleep(25);
            } catch (InterruptedException e) {
            } finally {
                currBranches += created;
                created = 0;
            }
        }
    }