class PathTrie {

    public Optional<T> get(String path) {
        List<String> components = getPathComponents(path);

        MatchTreeNode<T> node = tree.getLongestMatchingNode(components);
        if (node == null) {
            return Optional.empty();
        }

        T value;
        if (isExactlyMatchingPath(node, path, components)) {
            // exact match:
            value = node.value();
            if (value == null) {
                value = bestValue(node.parent());
            }
        } else {
            value = bestValue(node);
        }

        if (value == null) {
            return Optional.empty();
        }

        return Optional.of(value);
    }

    public  PathTrie();

}