I recently added some helper methods to OTrunkImpl (and some supporting functionality to XMLDatabase) which make it easier to find objects.
Find all loaded objects of a certain type:
Using OTrunkImpl.getAllObjects(Class), you will be returned an ArrayList<OTObject> with all loaded objects that can be cast to the passed in class.
Find objects with references to another object:
public ArrayList<OTID> getReferences(OTID objectID, Class<?> filterClass, boolean recurse, ArrayList<OTID> excludeIDs)
filterClass will filter the collection of parents by a certain class, similar to OTrunkImpl.getAllObjects(Class) does (can be null)
recursion sets whether to find indirect references (true), or only direct references (false) (assuming a heirarchy of a -> c, b -> c, c -> d; a and b are indirect references for d, c is a direct reference to d)
excludeIDs is a list of OTIDs which we don't want to include and don't want to recurse through (can be null)