if (curNode instanceof MathConnection) {
            queue.add(((MathConnection) curNode).getSecond());
        } else if (curNode != null) {
            queue.add(curNode);
        }