protected List<Node> getRelatedNodes(Node startNode, String type, Direction direction) {
   List<Node> result = new ArrayList<Node>();
   for (Relationship relationship :
       startNode.getRelationships(DynamicRelationshipType.withName(type), direction)) {
     result.add(relationship.getOtherNode(startNode));
   }
   return result;
 }
 protected Relationship makeFriends(Node from, Node to, int years) {
   Relationship friendship = from.createRelationshipTo(to, KNOWS);
   friendship.setProperty("Friendship.years", years);
   return friendship;
 }