Using RDKit to determine "nonring, nonterminal atoms"
I think you want to use SMARTS patterns to perform searches. These are something like &quot;regular expression&quot; patterns for molecular graphs.
At a rough guess, your query converts to [*R0!D1]:

* matches any atom (i.e., you don't care if it's a carbon or an oxygen)
R0 matches an atom in a ring with size 0 (i.e., not a ring atom)
D1 matches an atom with explicitly one bond (so !D1 matches atoms with more than one bond).

It's often helpful to use SMARTSview to test patterns.
More on RDKit's SMARTS support can be found in the documentation