.. include:: ../substitutions

.. oe:namespace:: OEChem

.. meta::
   :keywords: OEGetSubtree

.. oe:function:: OEGetSubtree

   .. oe:language:: c++ java csharp

      .. oe:api::

         OESystem::OEIterBase<OEAtomBase>* OEGetSubtree(const OEAtomBase* bgn,
                                                        const OEAtomBase* end,
                                                        unsigned int maxDepth = 0)

   .. oe:language:: python

      .. oe:api:: python

         OEGetSubtree(bgn: OEAtomBase, end: OEAtomBase, maxDepth: int = 0) -> OEAtomIter

   Traverses the subgraph from the **end** atom and avoids crossing over the bond to the
   **bgn** atom.

   *maxdepth*
     This parameter enables partial tree traversal in ring structures, default
     is zero which means full depth search.

   .. oe:language:: c++ java csharp

      .. oe:api::

         OESystem::OEIterBase<OEAtomBase>* OEGetSubtree(const OEBondBase*,
                                                        const OESystem::OEUnaryPredicate<OEAtomBase>& excludeAtoms,
                                                        unsigned int maxDepth = 0)

   .. oe:language:: python

      .. oe:api:: python

         OEGetSubtree(arg1: OEBondBase, excludeAtoms: OEUnaryAtomPred,
                      maxDepth: int = 0) -> OEAtomIter

   Traverses the subgraph from the beginning atom of the **bond** passed
   as the first argument without crossing the bond itself.

   If the subgraph traversal does not cross any atoms which return ``true`` when
   tested with the **excludeAtoms** predicate, then an iterator over the
   atoms contained in the subgraph is returned.  If 'excludeAtoms` are
   encountered in the subgraph traversal, the subgraph is discarded
   and a new traversal begins from the end atom of the bond.  If the
   new traversal fails to encounter excluded atoms then an iterator
   over the atoms contained in the subgraph is returned.  If both traversals
   fail then an iterator over an empty set of atoms is returned.

   *maxdepth*
     This parameter enables partial tree traversal in ring structures, default
     is zero which means full depth search.

   .. seealso::

      * :oe:func:`OEChem::OEGetSmallestSubtree` function
