code: public SimpleDependencyPath extend(DependencyRelation relation) {
          SimpleDependencyPath copy = copy();
          // Figure out which node is at the end of our path, and then add the new
          // node to the end of our nodes
          DependencyTreeNode last = last(); 
          copy.nodes.add((relation.headNode().equals(last)) 
                         ? relation.dependentNode() : relation.headNode());
          copy.path.add(relation);
          return copy;
      }
docs: Returns a copy of this dependency path that has the provided related
  appended to the end of its path sequence.