Commits

Takafumi Arakaki  committed a63b93d

added Orgnode.Root method.

  • Participants
  • Parent commits 0abfa5a

Comments (0)

Files changed (1)

         """
         return self.parent
 
+    def Root(self):
+        """
+        Return root node
+
+        What is root node?::
+
+          * I am node A, a root node       <- Root node!
+          ** I am a child of node A
+          ** I am a child of node A too
+          * I am also a root node            <- Root node!
+
+        """
+        child = self
+        while True:
+            parent = child.Parent()
+            if parent is None:
+                return child
+            child = parent
+
     def __repr__(self):
         """
         Print the level, heading text and tag of a node and the body