Node collapseTree Animation

When use node.CollapseTree or node.expandTree methods, the animation of expansion and collapse is missing. Though the functionality works as expected how can i get the animation back when manually expanding or collpasing nodes

$(
        'TreeExpanderButton',
        { ...treeExpanderObject, click: this.diagram.onClickOfTreeExpander },
        { position: new go.Point(224, 28) }
      )
  onClickOfTreeExpander = (e: any, obj: go.GraphObject) => {
    const node = this.dia.findNodeForKey(obj.part?.data.key);
    if (!node?.isTreeExpanded) {
      this.collapseAllPolicies();
      node?.expandTree();
    } else {
      node.collapseTree();
    }

Also how can i get the go.Node object if i have the go.Part. Right now i have to find the node again from diagram by the key.
const node = this.dia.findNodeForKey(obj.part?.data.key);

Don’t call the methods on the Node class, but the commands on the CommandHandler class, which not only perform transactions but may also perform pre-defined animations.

The GraphObject.part property returns whatever Part that is in (or just is, if it is a Part itself – so somePart.part === somePart). If that Part happens to be a Node, great. But it might be a Link or a Group or an Adornment or maybe even a subclass thereof. So if your obj is in the visual tree of a Node, your code should be:

const node = obj.part;