 whole subtree recursively
          collapseTree(node, portid);
        } else {
          // only expands immediate children and their links
          l.visible = true;
          var n = l.getOtherNode(node);
          if (n !== null) {
            n.location = node.getDocumentPoint(go.Spot.TopRight);
            n.visible = true;
          }
        }
      });
      myDiagram.toolManager.hideToolTip();
      node.diagram.commitTransaction('expand/collapse');
    }

    // recursive function for collapsi