public static boolean isValid(ParsingTreeNode node) {
        if ((node == null)
                ||(node.getSymbol() == null)) {
            return false;
        }
        if (node.getSymbol() instanceof NonTerminal) {
            if (node.hasChildren()) {
                for (int i = 0; i < node.getChildrenCount(); i++) {
                    if (!isValid(node.getChild(i))) {
                        return false;
                    }
                }
                return true;
            } else {
                return false;
            }
        } else {
            return !node.hasChildren();
        }
    }