private void removeUnnecessaryData() { Set<AtomType> clear = Sets.newHashSet(); List<Atom> atoms = Lists.newArrayList(); List<AtomType> atomTypes = structure.getAtomTypes(); for (Section section : structure.getSections()) { if (section.getSectionType().equals(SectionType.STRUCTUREDATA)) { atoms.addAll(section.getAtoms()); } } for (AtomType atomType : atomTypes) { AtomType delete = atomType; for (Atom atom : atoms) { if (atomType.getName().contains(atom.getType())) { delete = null; } } if (delete != null) { clear.add(delete); } } clear.forEach(atomTypes::remove); }