boolean (@NotNull List<String> parts) { if (parts.isEmpty()) { return children.length == 0; } String name = parts.remove(parts.size()-1); int index = binarySearchChildByName(name); if (index < 0) { return false; } FilePartNode child = children[index]; boolean toRemove = child.removeEmptyNodesByPath(parts); if (toRemove) { children = children.length == 1 ? EMPTY_ARRAY : ArrayUtil.remove(children, child); return children.length == 0 && leaves == null; } return false; }