Element (@Nullable Element element, String path) { int i = 0; while (element != null) { int dot = path.indexOf('.', i); if (dot == -1) { return element.getChild(path.substring(i)); } element = element.getChild(path.substring(i, dot)); i = dot + 1; } return null; }