public static List<String> stripDotPathComponents(List<String> input) {
        List<String> output = new ArrayList<>();
        for (String string : input) {
            if (string.equals("..")) {
                if (!output.isEmpty()) {
                    output.remove(output.size() - 1);
                }
            } else if (!string.equals(".")) {
                output.add(string);
            }
        }
        return output;
    }
@Test
    public void testStripDotPathComponents() {

        //double dots
        assertEquals(Arrays.asList("keep", "keep2"), CommandUtils.stripDotPathComponents(Arrays.asList("..", "keep", "keep2")));
        //single dots
        assertEquals(Arrays.asList("keep", "keep2"), CommandUtils.stripDotPathComponents(Arrays.asList(".", "keep", "keep2")));

        assertEquals(Arrays.asList(".keep", "keep2"), CommandUtils.stripDotPathComponents(Arrays.asList(".", ".keep", "keep2")));

        assertEquals(Arrays.asList(".keep", "keep2"), CommandUtils.stripDotPathComponents(Arrays.asList("..", ".keep", "keep2")));

    }