code: def whichrestype(atom):
      
      atom = atom if not isinstance(atom, Atom) else atom.OBAtom  # Convert to OpenBabel Atom
      return atom.GetResidue().GetName() if atom.GetResidue() is not None else None
docs: Returns the residue name of an Pybel or OpenBabel atom.