code: function() {
              var parent = this.getParent(),
                  ancestors = new Kinetic.Collection();
  
              while (parent) {
                  ancestors.push(parent);
                  parent = parent.getParent();
              }
  
              return ancestors;
          }
docs: get ancestors
  @method
  @memberof Kinetic.Node.prototype
  @returns {Kinetic.Collection}
  @example
  shape.getAncestors().each(function(node) {
  console.log(node.getId());
  })