code: public static WebElement createObject(RemoteWebDriver driver, Map<String, Object> ro) {
      String ref = ro.get("ELEMENT").toString();
  
      String type = (String) ro.get("type");
      if (type != null) {
        String remoteObjectName = "org.uiautomation.ios.client.uiamodels.impl.Remote" + type;
  
        if ("UIAElementNil".equals(type)) {
          return null;
        }
  
        boolean isArray = false; // uiObject.has("length");
  
        Object[] args = null;
        Class<?>[] argsClass = null;
  
        if (isArray) {
          // args = new Object[] {driver, ref, uiObject.getInt("length")};
          // argsClass = new Class[] {RemoteIOSDriver.class, String.class,
          // Integer.class};
        } else {
          args = new Object[]{driver, ref};
          argsClass = new Class[]{RemoteWebDriver.class, String.class};
        }
        try {
          Class<?> clazz = Class.forName(remoteObjectName);
          Constructor<?> c = clazz.getConstructor(argsClass);
          Object o = c.newInstance(args);
          RemoteWebElement element = (RemoteWebElement) o;
          element.setFileDetector(driver.getFileDetector());
          element.setParent(driver);
          element.setId(ref);
          return (RemoteIOSObject) o;
        } catch (Exception e) {
          throw new WebDriverException("error casting", e);
        }
      } else {
        RemoteWebElement element = new RemoteWebElement();
        element.setFileDetector(driver.getFileDetector());
        element.setId(ref);
        element.setParent(driver);
        return element;
      }
  
  
    }
docs: Uses reflection to instanciate a remote object implementing the correct interface.
  
  @return the object. If the object is UIAElementNil, return null for a simple object, an empty
  list for a UIAElementArray.