Design a hierarchical key-value path store supporting four operations on UNIX-style absolute paths (e.g., "/a/b"). Implement:
-
create(path, value): create a new node with value; the parent path must already exist (except root "/"), and the path must not already exist.
-
set(path, value): update the value of an existing path; fail if the path does not exist.
-
get(path): retrieve the value stored at path; indicate absence if the path does not exist.
-
remove(path): delete the specified path only if it has no children; otherwise fail. Choose appropriate return types and error signaling for each method (e.g., boolean success flags, exceptions, or optionals) and document your choices. Define assumptions about valid path syntax (no trailing slash except root, segments separated by single "/", non-empty segments) and initial state (root exists and may or may not hold a value, your choice—justify it). Optimize for time/space; explain the data structures you use and the complexity of each operation. Finally, write a minimal but thorough set of unit tests that validate normal behavior and edge cases, including: creating under a missing parent, duplicate create, set on missing path, get on missing path, remove on non-leaf, remove on leaf, operations involving root, and malformed paths.