def check_node_link(link, stack)
      if (node = instance_variable_get('@' + link))
        # Node links must only be of class SpaceTreeNodeLink
        unless node.nil? || node.is_a?(SpaceTreeNodeLink)
          PEROBS.log.error "Node link #{link} of node #{to_s} " +
            "is of class #{node.class}"
          return false
        end

        # Link must not point back to self.
        if node == self
          PEROBS.log.error "#{link} address of node " +
            "#{node.to_s} points to self #{to_s}"
          return false
        end

        # Link must not point to any of the parent nodes.
        if stack.include?(node)
          PEROBS.log.error "#{link} address of node #{to_s} " +
            "points to parent node #{node}"

            return false
        end

        # Parent link of node must point back to self.
        if node.parent != self
          PEROBS.log.error "@#{link} node #{node.to_s} does not have parent " +
            "link pointing " +
            "to parent node #{to_s}. Pointing at " +
            "#{node.parent.nil? ? 'nil' : node.parent.to_s} instead."

          return false
        end
      end

      true
    end
def check_node_link(link, stack)
      if (node = instance_variable_get('@' + link))
        # Node links must only be of class SpaceTreeNodeLink
        unless node.nil? || node.is_a?(SpaceTreeNodeLink)
          PEROBS.log.error "Node link #{link} of node #{to_s} " +
            "is of class #{node.class}"
          return false
        end

        # Link must not point back to self.
        if node == self
          PEROBS.log.error "#{link} address of node " +
            "#{node.to_s} points to self #{to_s}"
          return false
        end

        # Link must not point to any of the parent nodes.
        if stack.include?(node)
          PEROBS.log.error "#{link} address of node #{to_s} " +
            "points to parent node #{node}"

            return false
        end

        # Parent link of node must point back to self.
        if node.parent != self
          PEROBS.log.error "@#{link} node #{node.to_s} does not have parent " +
            "link pointing " +
            "to parent node #{to_s}. Pointing at " +
            "#{node.parent.nil? ? 'nil' : node.parent.to_s} instead."

          return false
        end
      end

      true
    end
Check the integrity of the given sub-node link and the parent link
 pointing back to this node.
 @param link [String] 'smaller', 'equal' or 'larger'
 @param stack [Array] List of parent nodes [ address, mode ] touples
 @return [Boolean] true of OK, false otherwise