This paper presents an algorithm to do motion planning for a new class of self-reconfigurable modular robot: the variable topology truss (VTT). Modular robots consist of many modules that can be configured into various structures, and motion planning problem for modular robots with many degrees of freedom and many motion constraints is a significant challenge. In this paper, we propose a novel motion planning algorithm for modular robots to handle this problem with huge state space inspired by DNA replication process — the topology of DNA can be changed by cutting and resealing strands as tanglements form. In a variable topology truss, a single node with enough edge modules can split into a pair of nodes and two separate nodes can be merged to become an individual one. This self-reconfiguration ability results in more potential applications for this type of robots in unstructured environment, such as space and underseas but also leads to more challenges for reconfiguration planning. A novel way to model the robot in a nonuniform grid space is presented and a simple local planner is also developed to check the validation of possible actions. This approach significantly simplifies the problem and some experiment results show that the complicated problem can be solved in a reasonable time.