public void remove(Node head){
        if(head == null || head.next == null){
            return;
        }
        Node curr = head;
        Node next = head.next;
        Node nextNext = head.next.next;
        while(nextNext != null){
            
            Point pcurr = (Point)curr.obj;
            Point pnext = (Point)nextNext.obj;
            if(pcurr.x == pnext.x || pcurr.y == pnext.y){
                curr.next = nextNext;
                next = nextNext;
                nextNext = nextNext.next;
            }else{
                curr = curr.next;
                next = next.next;
                nextNext = nextNext.next;
            }
            
        }
    }
http://www.geeksforgeeks.org/given-linked-list-line-segments-remove-middle-points/
@author tusroy
Test cases:
0 or more nodes
All points are edge of line segments so nothing gets removed
One long line so all points in between get removed
src/com/interview/linklist/RemoveMiddleElementsOfLineSegment.java