public boolean containsPath(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 true;
        }

        String[] pathTokens = path.split(Pattern.quote("/"));
        Map<Object, Object> subMap = map;

        for (int i = 1; i < pathTokens.length; i++) {
            try {
                if (subMap.containsKey(pathTokens[i])) {
                    subMap = (Map<Object, Object>) subMap.get(pathTokens[i]);
                } else {
                    return false;
                }
            } catch (NullPointerException | ClassCastException e) {
                return false;
            }
        }

        return true;
    }
@Test
    public void testContainsPath() throws IOException {
        YamlMapAccessor yamlMapAccessor = createYamlMapAccessor("/YamlMapAccessorTest.yaml");

        assertTrue(yamlMapAccessor.containsPath("/"));

        assertTrue(yamlMapAccessor.containsPath("/key"));
        assertTrue(yamlMapAccessor.containsPath("/key/subkey"));
        assertFalse(yamlMapAccessor.get("/key/subkey").isPresent());

        assertTrue(yamlMapAccessor.containsPath("/key2"));
        assertTrue(yamlMapAccessor.containsPath("/key2/subkey2"));
        assertTrue(yamlMapAccessor.get("/key2/subkey2").isPresent());

        assertFalse(yamlMapAccessor.containsPath("/key/foo"));
    }