class LinkkiInMemoryContainer extends com.vaadin.v7.data.util.AbstractInMemoryContainer<T, Object, com.vaadin.v7.data.Item> implements com.vaadin.v7.data.Container.Hierarchical {

    @Override
    @SuppressWarnings({ "unchecked" })
    public Collection<T> getChildren(Object itemId) {
        List<T> newChildren = children.computeIfAbsent((T)itemId, this::getChildrenTypesafe);
        newChildren.forEach(c -> {
            if (!containsId(c)) {
                getAllItemIds().add(c);
            }
        });
        return newChildren;
    }

}