### Question:
Util { public static PathAddress getParentAddressByKey(PathAddress address, String parentKey) { for (int i = address.size() - 1; i >= 0; i--) { PathElement pe = address.getElement(i); if (parentKey.equals(pe.getKey())) { return address.subAddress(0, i + 1); } } return null; } private  Util(); static String getNameFromAddress(final ModelNode address); static String getNameFromAddress(PathAddress address); static ModelNode createAddOperation(final PathAddress address); static ModelNode createAddOperation(); static ModelNode createRemoveOperation(final PathAddress address); static ModelNode createOperation(final String operationName, final PathAddress address); static ModelNode createOperation(final OperationDefinition operationDefinition, final PathAddress address); static ModelNode createEmptyOperation(String operationName, final PathAddress address); static ModelNode getEmptyOperation(String operationName, ModelNode address); static ModelNode getResourceRemoveOperation(final PathAddress address); static ModelNode getWriteAttributeOperation(ModelNode address, String attributeName, String value); static ModelNode getWriteAttributeOperation(final PathAddress address, String attributeName, int value); static ModelNode getWriteAttributeOperation(final PathAddress address, String attributeName, boolean value); static ModelNode getWriteAttributeOperation(final ModelNode address, String attributeName, ModelNode value); static ModelNode getWriteAttributeOperation(final PathAddress  address, String attributeName, String value); static ModelNode getWriteAttributeOperation(final PathAddress address, String attributeName, ModelNode value); static ModelNode getReadAttributeOperation(final PathAddress address, String attributeName); static ModelNode getReadResourceDescriptionOperation(final PathAddress address); static ModelNode getUndefineAttributeOperation(final PathAddress address, String attributeName); static boolean isExpression(String value); static ModelNode getOperation(final String operationName, final PathAddress address, final ModelNode params); static ModelNode getOperation(String operationName, ModelNode address, ModelNode params); static PathAddress getParentAddressByKey(PathAddress address, String parentKey); static ModelNode validateOperation(ModelNode operation);  }### Answer:
@Test public void testGetParentAddressByKey() { PathAddress address = PathAddress.pathAddress(PathElement.pathElement("system", "test"), PathElement.pathElement("subsystem", "subtest"), PathElement.pathElement("test"), PathElement.pathElement("resource", "testResource")); assertThat(Util.getParentAddressByKey(address, "subsystem"), is(PathAddress.pathAddress( PathElement.pathElement("system", "test"), PathElement.pathElement("subsystem", "subtest")))); assertThat(Util.getParentAddressByKey(address, "system"), is(PathAddress.pathAddress( PathElement.pathElement("system", "test")))); assertThat(Util.getParentAddressByKey(address, "test"), is(PathAddress.pathAddress( PathElement.pathElement("system", "test"), PathElement.pathElement("subsystem", "subtest"), PathElement.pathElement("test")))); }