public Optional<Object> get(String path) {
        if (path == null || path.trim().isEmpty()) {
            throw new IllegalArgumentException(String.format("path [%s] is invalid", path));
        }

        path = validatePath(path);
        if (path.equals("/")) {
            return Optional.of(map);
        }

        String[] pathTokens = path.split(Pattern.quote("/"));
        Object object = map;

        for (int i = 1; i < pathTokens.length; i++) {
            try {
                object = resolve(pathTokens[i], object);
            } catch (NullPointerException | ClassCastException e) {
                return Optional.empty();
            }
        }

        return Optional.ofNullable(object);
    }
@Test
    public void testInvalidPaths() throws IOException {
        YamlMapAccessor yamlMapAccessor = createYamlMapAccessor("/YamlMapAccessorTest.yaml");

        try {
            yamlMapAccessor.get("");
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // DO NOTHING
        }

        try {
            yamlMapAccessor.get("//");
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // DO NOTHING
        }

        try {
            yamlMapAccessor.get("foo");
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // DO NOTHING
        }

        try {
            yamlMapAccessor.get("/foo/");
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // DO NOTHING
        }
    }