code: function insideElement(from, to, fromBBox, toBBox, bearing) {
  
          var route = {};
          var boundary = fromBBox.union(toBBox).inflate(1);
  
          // start from the point which is closer to the boundary
          var reversed = boundary.center().distance(to) > boundary.center().distance(from);
          var start = reversed ? to : from;
          var end = reversed ? from : to;
  
          var p1, p2, p3;
  
          if (bearing) {
              // Points on circle with radius equals 'W + H` are always outside the rectangle
              // with width W and height H if the center of that circle is the center of that rectangle.
              p1 = g.Point.fromPolar(boundary.width + boundary.height, radians[bearing], start);
              p1 = boundary.pointNearestToPoint(p1).move(p1, -1);
  
          } else {
              p1 = boundary.pointNearestToPoint(start).move(start, 1);
          }
  
          p2 = freeJoin(p1, end, boundary);
  
          if (p1.round().equals(p2.round())) {
              p2 = g.Point.fromPolar(boundary.width + boundary.height, g.toRad(p1.theta(start)) + Math.PI / 2, end);
              p2 = boundary.pointNearestToPoint(p2).move(end, 1).round();
              p3 = freeJoin(p1, p2, boundary);
              route.points = reversed ? [p2, p3, p1] : [p1, p3, p2];
  
          } else {
              route.points = reversed ? [p2, p1] : [p1, p2];
          }
  
          route.direction = reversed ? getBearing(p1, to) : getBearing(p2, to);
  
          return route;
      }
docs: Finds route for situations where one element is inside the other. Typically the route is directed outside the outer element first and then back towards the inner element.