DepUtils { static public Collection<URI> removeRedundantPaths(Collection<URI> uris) { List<URI> result = new ArrayList<URI>(); for (URI uri : uris) { String path = uri.getPath(); if (!path.endsWith("/")) { path += "/"; } boolean addIt = true; for (int i = 0; i < result.size(); i++) { URI testUri = result.get(i); if (!StringUtils.equals(testUri.getScheme(), uri.getScheme()) || !StringUtils.equals(testUri.getHost(), uri.getHost()) || testUri.getPort() != uri.getPort()) { continue; } String test = testUri.getPath(); if (!test.endsWith("/")) { test += "/"; } if (path.equals(test) || path.startsWith(test)) { addIt = false; break; } else if (test.startsWith(path)) { result.remove(i); } } if (addIt) result.add(uri); } return result; }  static Collection<URI> removeRedundantPaths(Collection<URI> uris); static DepTreeNode getNodeForResource(URI requestUri,
			Map<URI, DepTreeNode> dependencies); static ParseResult parseDependencies(Node node, Set<String> dependentFeatures);  }
@Test public void testRemoveRedundantPaths() throws URISyntaxException { URI[] names = new URI[] { new URI("/a/a/a"), new URI("/a/b"), new URI("/a/c"), new URI("/a/c/a"), new URI("/b/a/a"), new URI("/b/a/a/a"), new URI("/a/a/b") }; URI[] expected = new URI[] { new URI("/a/a/a"), new URI("/a/b"), new URI("/a/c"), new URI("/b/a/a"), new URI("/a/a/b") }; Collection<URI> list = new ArrayList<URI>(Arrays.asList(names)); list = DepUtils.removeRedundantPaths(list); assertEquals(5, list.size()); assertTrue(list.containsAll(Arrays.asList(expected))); }