original_string: protected static function get_tree($userid, $capability) {
          // Extract raw capability data for this user and capability.
          $pathroleperms = self::get_capability_info_at_each_context($userid, $capability);
  
          // Convert the raw data into a permission tree based on context.
          $root = self::calculate_permission_tree($pathroleperms);
          unset($pathroleperms);
  
          // Simplify the permission tree by removing unnecessary nodes.
          $root = self::remove_negative_subtrees($root);
          self::remove_duplicate_nodes($root);
  
          // Return the tree.
          return $root;
      }
code: protected static function get_tree($userid, $capability) {
          // Extract raw capability data for this user and capability.
          $pathroleperms = self::get_capability_info_at_each_context($userid, $capability);
  
          // Convert the raw data into a permission tree based on context.
          $root = self::calculate_permission_tree($pathroleperms);
          unset($pathroleperms);
  
          // Simplify the permission tree by removing unnecessary nodes.
          $root = self::remove_negative_subtrees($root);
          self::remove_duplicate_nodes($root);
  
          // Return the tree.
          return $root;
      }
code_tokens: protected static function get_tree ( $ userid , $ capability ) { // Extract raw capability data for this user and capability. $ pathroleperms = self :: get_capability_info_at_each_context ( $ userid , $ capability ) ; // Convert the raw data into a permission tree based on context. $ root = self :: calculate_permission_tree ( $ pathroleperms ) ; unset ( $ pathroleperms ) ; // Simplify the permission tree by removing unnecessary nodes. $ root = self :: remove_negative_subtrees ( $ root ) ; self :: remove_duplicate_nodes ( $ root ) ; // Return the tree. return $ root ; }
docstring: Gets a permission tree for the given user and capability, representing the value of that
  capability at different contexts across the system. The tree will be simplified as far as
  possible.
  
  The output is the root of a tree of stdClass objects with the fields 'path' (a context path),
  'allow' (true or false), and 'children' (an array of similar objects).
  
  @param int $userid User id
  @param string $capability Capability e.g. 'moodle/course:view'
  @return \stdClass Root node of tree
docstring_tokens: Gets a permission tree for the given user and capability representing the value of that capability at different contexts across the system . The tree will be simplified as far as possible .