<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_heteroatoms(self, elements=None):
 """ Identify non-H, non-C atoms in the MoleculeGraph, returning a list of their node indices. :param elements: List of elements to identify (if only certain functional groups are of interest). :return: set of ints representing node indices """


        heteroatoms = set()

        for node in self.molgraph.graph.nodes():
            if elements is not None:
                if str(self.species[node]) in elements:
                    heteroatoms.add(node)
            else:
                if str(self.species[node]) not in ["C", "H"]:
                    heteroatoms.add(node)

        return heteroatoms