title: Optimizing nested if/ then, java
body: <p>This code's only redeeming quality is that it works. Can you please help me structure it better?</p>
  
  <pre><code>if (profile.isIgnoreCase()) {
      // ignore case
      if (masterKey.equalsIgnoreCase((targetKey))) {
      if (masterValue.equalsIgnoreCase(targetValue)) {
          doOK(masterKey, masterValue);
          break;
      } else {
          // Key is either Missing or is an Error
          if (checkErrors) {
          doError(masterKey, masterValue, targetValue);
          break;
          }
      }
      }
  } else {
      if (masterKey.equals(targetKey)) {
      if (masterValue.equals(targetValue)) {
          doOK(masterKey, masterValue);
          break;
      } else {
          if (checkErrors) {
          doError(masterKey, masterValue, targetValue);
          break;
          }
      }
      }
  }
  </code></pre>