code: public static void processConditions(final String condition, final Document doc, final String defaultCondition,
              boolean removeConditionAttr) {
          final Map<Node, List<String>> conditionalNodes = getConditionNodes(doc.getDocumentElement());
  
          // Loop through each condition found and see if it matches
          for (final Map.Entry<Node, List<String>> entry : conditionalNodes.entrySet()) {
              final Node node = entry.getKey();
              final List<String> nodeConditions = entry.getValue();
              boolean matched = false;
  
              // Check to see if the condition matches
              for (final String nodeCondition : nodeConditions) {
                  if (condition != null && nodeCondition.matches(condition)) {
                      matched = true;
                  } else if (condition == null && defaultCondition != null && nodeCondition.matches(defaultCondition)) {
                      matched = true;
                  }
              }
  
              // If there was no match then remove the node
              if (!matched) {
                  final Node parentNode = node.getParentNode();
                  if (parentNode != null) {
                      parentNode.removeChild(node);
                  }
              } else if (removeConditionAttr) {
                  // Remove the condition attribute so that it can't get processed by something else downstream
                  ((Element) node).removeAttribute("condition");
              }
          }
      }
docs: Check the XML Document and it's children for condition
  statements. If any are found then check if the condition
  matches the passed condition string. If they don't match
  then remove the nodes.
  
  @param condition           The condition regex to be tested against.
  @param doc                 The Document to check for conditional statements.
  @param defaultCondition    The default condition to allow a default block when processing conditions.
  @param removeConditionAttr Remove the condition attribute from any matching/leftover nodes.