private List<Element> getChildElements(final String fromElementId,
                                           final Map<String, Element> elementInstances,
                                           final Map<Element, PipelineElementType> elementTypeMap,
                                           final Map<String, Set<String>> linkSets,
                                           final SteppingController controller) {
        List<Element> childElements = Collections.emptyList();

        final Set<String> toElementIdSet = linkSets.get(fromElementId);
        if (toElementIdSet != null && !toElementIdSet.isEmpty()) {
            childElements = new ArrayList<>(toElementIdSet.size());

            for (final String toElementId : toElementIdSet) {
                final Element to = elementInstances.get(toElementId);
                // If the element we are linking to does not exist then we can't
                // link.
                if (to != null) {
                    // If we are stepping then filter the descendants so we only
                    // include ones that are appropriate for stepping.
                    if (controller != null) {
                        final PipelineElementType elementType = elementTypeMap.get(to);
                        if (elementType.hasRole(PipelineElementType.VISABILITY_STEPPING)) {
                            childElements.add(to);
                        } else {
                            childElements.addAll(getChildElements(toElementId, elementInstances, elementTypeMap,
                                    linkSets, controller));
                        }
                    } else {
                        childElements.add(to);
                    }
                }
            }
        }

        return childElements;
    }
Get child elements for the given parent or descendants if some
intermediate children are to be excluded due to stepping mode being used.

@param fromElementId    The id of the element to get children or descendant elements
                        for. If this is null then root elements will be returned.
@param elementInstances A map of element ids to element instances.
@param elementTypeMap   A map of element instances to element types.
@param linkSets         A map of links keyed by element ids to link from, to sets of
                        element ids that are linked to.
@param controller       The stepping controller. Null if we are not stepping.
@return A list of immediate child or descendant elements for the supplied
parent element id.
stroom-pipeline/src/main/java/stroom/pipeline/factory/PipelineFactory.java