public ArrayList<Link> getPrevLinksForNode(Node node, ArrayList<Link> prevLinks) {
        boolean found = false;
        if (this.getP2() == node) {
            for (Link link : prevLinks) {
                if (link == this) {
                    found = true;
                }
            }
            if (!found) {
                prevLinks.add(this);
            }
        }
        for (Link currentLink : links) {
            prevLinks = currentLink.getPrevLinksForNode(node, prevLinks);
        }
        return prevLinks;
    }