// This sample shows how to access all descendants
    // (either direct or indirect) of a node

    // Check if there is an active node in the diagram
    if (!(diagram.getActiveItem() instanceof DiagramNode))
      return;

    // A list where the descendant nodes will be stored
    ArrayList<DiagramNode> descendants = new ArrayList<DiagramNode>();

    // A queue containing nodes which are yet to be visited
    LinkedList<DiagramNode> remaining = new LinkedList<DiagramNode>();
    remaining.offer((DiagramNode)diagram.getActiveItem());
    while (remaining.size() 0)
    {
      DiagramNode n = remaining.poll();

      // Traverse all outgoing links and add their
      // destination nodes to the descendant list
      for (DiagramLink link : n.getOutgoingLinks())
      {
        if (!descendants.contains(link.getDestination()))
        {
          descendants.add(link.getDestination());
          remaining.offer(link.getDestination());
        }
      }
    }

    // Color the successor nodes
    for (DiagramNode n : descendants)
      n.setBrush(new SolidBrush(new Color(1242520)));