void addFields( String prefix, Set<String> fieldNames, XmlObject field ) {
    //Salesforce SOAP Api sends IDs always in the response, even if we don't request it in SOQL query and
    //the id's value is null in this case. So, do not add this Id to the fields list
    if ( isNullIdField( field ) ) {
      return;
    }
    String fieldname = prefix + field.getName().getLocalPart();
    if ( field instanceof SObject ) {
      SObject sobject = (SObject) field;
      for ( XmlObject element : SalesforceConnection.getChildren( sobject ) ) {
        addFields( fieldname + ".", fieldNames, element );
      }
    } else {
      addField( fieldname, fieldNames, (String) field.getValue() );
    }
  }
@Test
  public void testAddFields_IdAdded() throws Exception {
    final Set<String> fields = new LinkedHashSet<>();
    XmlObject testObject = createObject( "Id", VALUE, ObjectType.XMLOBJECT );
    dialog.addFields( "", fields, testObject );
    assertArrayEquals( "Id field added", new String[]{"Id"}, fields.toArray() );
  }