public static ResourceId fromInstanceIdentifier(String input) {

        String[] nodes = input.split("/");
        List<NodeKey> nodeKeys = Arrays.stream(nodes)
            .filter(s -> !s.isEmpty())
            .map(ResourceIds::toNodeKey)
            .collect(Collectors.toList());

        if (nodeKeys.isEmpty()) {
            return null;
        }

        Builder builder = ResourceId.builder();

        // fill-in null (=inherit from parent) nameSpace
        String lastNamespace = null;
        for (NodeKey nodeKey : nodeKeys) {
            if (nodeKey.schemaId().namespace() != null) {
                lastNamespace = nodeKey.schemaId().namespace();
            }
            if (nodeKey instanceof LeafListKey) {
                builder.addLeafListBranchPoint(nodeKey.schemaId().name(),
                                               firstNonNull(nodeKey.schemaId().namespace(), lastNamespace),
                                               ((LeafListKey) nodeKey).value());

            } else if (nodeKey instanceof ListKey) {
                builder.addBranchPointSchema(nodeKey.schemaId().name(), lastNamespace);
                for (KeyLeaf kl : ((ListKey) nodeKey).keyLeafs()) {
                    builder.addKeyLeaf(kl.leafSchema().name(),
                                       firstNonNull(kl.leafSchema().namespace(), lastNamespace),
                                       kl.leafValue());
                }
            } else {
                builder.addBranchPointSchema(nodeKey.schemaId().name(), lastNamespace);
            }
        }
        return builder.build();
    }
@Test
    public void testFromInstanceIdentifier() {

        ResourceId eth0 = ResourceId.builder()
                .addBranchPointSchema("interfaces", "ietf-interfaces")
                .addBranchPointSchema("interface", "ietf-interfaces")
                .addKeyLeaf("name", "ietf-interfaces", "eth0")
                .build();
        assertThat(ResourceIds.fromInstanceIdentifier("/ietf-interfaces:interfaces/interface[name=\"eth0\"]"),
                   is(eth0));

        assertThat("fromInstanceIdentifier return path relative to virtual root",
                   ResourceIds.fromInstanceIdentifier("/org.onosproject.dcs:devices"),
                   is(ResourceIds.relativize(ResourceIds.ROOT_ID, DEVICES_ID)));

        assertThat(ResourceIds.prefixDcsRoot(
                     ResourceIds.fromInstanceIdentifier("/org.onosproject.dcs:devices")),
                   is(DEVICES_ID));

        assertThat(ResourceIds.fromInstanceIdentifier("/"),
                    is(nullValue()));

        DeviceId deviceId = DeviceId.deviceId("test:device-identifier");
        assertThat(ResourceIds.prefixDcsRoot(
                 fromInstanceIdentifier("/org.onosproject.dcs:devices/device[device-id=\"test:device-identifier\"]")),
                   is(toResourceId(deviceId)));

    }