code: function relativePosition(dim, val) {
      var ele = this[0];
      var cy = this.cy();
      var ppos = plainObject(dim) ? dim : undefined;
      var setting = ppos !== undefined || val !== undefined && string(dim);
      var hasCompoundNodes = cy.hasCompoundNodes();
  
      if (ele && ele.isNode()) {
        // must have an element and must be a node to return position
        if (setting) {
          for (var i = 0; i < this.length; i++) {
            var _ele2 = this[i];
            var parent = hasCompoundNodes ? _ele2.parent() : null;
            var hasParent = parent && parent.length > 0;
            var relativeToParent = hasParent;
  
            if (hasParent) {
              parent = parent[0];
            }
  
            var origin = relativeToParent ? parent.position() : {
              x: 0,
              y: 0
            };
  
            if (val !== undefined) {
              // set one dimension
              _ele2.position(dim, val + origin[dim]);
            } else if (ppos !== undefined) {
              // set whole position
              _ele2.position({
                x: ppos.x + origin.x,
                y: ppos.y + origin.y
              });
            }
          }
        } else {
          // getting
          var pos = ele.position();
  
          var _parent = hasCompoundNodes ? ele.parent() : null;
  
          var _hasParent = _parent && _parent.length > 0;
  
          var _relativeToParent = _hasParent;
  
          if (_hasParent) {
            _parent = _parent[0];
          }
  
          var _origin = _relativeToParent ? _parent.position() : {
            x: 0,
            y: 0
          };
  
          ppos = {
            x: pos.x - _origin.x,
            y: pos.y - _origin.y
          };
  
          if (dim === undefined) {
            // then return the whole rendered position
            return ppos;
          } else {
            // then return the specified dimension
            return ppos[dim];
          }
        }
      } else if (!setting) {
        return undefined; // for empty collection case
      }
  
      return this; // chaining
    }
docs: get/set the position relative to the parent