### Question:
RadixTree { public List<RadixNode<T>> getLongestPrefixPath(String path) { RadixNode n = root; Path p = Paths.get(path); int level = 0; List<RadixNode<T>> result = new ArrayList<>(); result.add(root); while (level < p.getNameCount()) { HashMap<String, RadixNode> children = n.getChildren(); if (children.isEmpty()) { break; } String component = p.getName(level).toString(); if (children.containsKey(component)) { n = children.get(component); result.add(n); level++; } else { break; } } return result; } RadixTree(); boolean isEmpty(); void insert(String path); void insert(String path, T val); RadixNode<T> getLastNodeInPrefixPath(String path); void removePrefixPath(String path); List<RadixNode<T>> getLongestPrefixPath(String path); @VisibleForTesting /** * Convert radix path to string format for output. * @param path - radix path represented by list of radix nodes. * @return radix path as string separated by "/". * Note: the path will always be normalized with and ending "/". */ static String radixPathToString(List<RadixNode<Integer>> path); String getLongestPrefix(String path);  }### Answer:
@Test public void testGetLongestPrefixPath() { List<RadixNode<Integer>> lpp = ROOT.getLongestPrefixPath("/a/b/c/d/g/p"); RadixNode<Integer> lpn = lpp.get(lpp.size()-1); assertEquals("g", lpn.getName()); lpn.setValue(100); List<RadixNode<Integer>> lpq = ROOT.getLongestPrefixPath("/a/b/c/d/g/q"); RadixNode<Integer> lqn = lpp.get(lpq.size()-1); System.out.print(RadixTree.radixPathToString(lpq)); assertEquals(lpn, lqn); assertEquals("g", lqn.getName()); assertEquals(100, (int)lqn.getValue()); assertEquals("/a/", RadixTree.radixPathToString( ROOT.getLongestPrefixPath("/a/g"))); }