class SectionServiceImpl implements SectionService {

    @Override
    public List<SectionResource> filterParentSections(List<SectionResource> sections) {
        if (sections == null) {
            return new ArrayList<>();
        }

        List<SectionResource> childSections = getChildSections(sections, new ArrayList<>());

        return sections.stream()
                .filter(s -> childSections.stream()
                        .noneMatch(c -> c.getId().equals(s.getId())))
                .sorted(Comparator.comparing(SectionResource::getPriority))
                .collect(toList());
    }

}